Hi,
I did once more did not help: Code states the same "not connected". I used BLE functionality here and it works. Anyway problem happens even with minimalistic mqtt code.
// Scan options
let scanOptions = {
duration_ms: BLE.Scanner.INFINITE_SCAN, // Scan indefinitely
active: false, // Use passive scanning
interval_ms: 150,
window_ms: 50,
};
// Scan callback
function scanCB(ev, res) {
if (ev !== BLE.Scanner.SCAN_RESULT) return;
// Get the address and signal strength of the beacon
let addr = res.addr;
let rssi = res.rssi;
// Publish the beacon data to the MQTT topic
//MQTT.publish("beacons", JSON.stringify({ addres: addr, signal: rssi }));
//print(addr);
}
// Start scanning
BLE.Scanner.Start(scanOptions, scanCB);
// Publish a message every 10 seconds to confirm that the code is running
function mqttWatchdog(){
let status = MQTT.isConnected();
if(status){
print("Running");
MQTT.publish("beacons", "Running", 0, true);
print("Running");
} else {
print("Not connected");
}
}
Timer.set(2000, true, mqttWatchdog);
pasted-from-clipboard.png
pasted-from-clipboard.png