First of all, OpenMQTTGateway is an amazing project. It’s massive overkill for what I’m trying to do today, but now that I’ve seen what it can do, I’ll be looking for ideas to use it with.
What I’m trying to do today is to use cron on my linux machine to issue a press command to the one switchbot I own, because my phone is usually too far away from my dehumidifier when I want to turn it on and off. I’ve tried linux-only options and several esp32 options. This is my first exposure to BLE.
My SwitchBot is a “SWITCHBOT-S1” (according to Amazon) with mac D5:35:33:34:3C:5F, running firmware 6.6 (I’m pretty sure it’s 6.6 – my phone app isn’t showing the version right now). I’m running OpenMQTTGateway on a Lolin D32 Pro. I’ve also tried it on an ESP32 Thing and a non-Pro Lolin D32 with the same core panic issue.
I’m probably doing something wrong, but here’s what I hope are all the relevant details. I appreciate any help or advice!
My MQTT command:
$ mosquitto_pub -h 192.168.1.12 -t home/OMG_ESP32_BLE/commands/MQTTtoBT -m ‘{“ble_write_address”:“D5:35:33:34:3C:5F”, “mac_type”:1, “ble_write_service”:“cba20d00-224d-11e6-9fb8-0002a5d5c51b”, “ble_write_char”:“cba20002-224d-11e6-9fb8-0002a5d5c51b”, “ble_write_value”:“5701”, “value_type”:“HEX”, “ttl”:4, “immediate”:true }’
Relevant ESP32 console output:
…
N: Device detected: D5:35:33:34:3C:5F
…
N: Send on /BTtoMQTT/D53533343C5F msg {“id”:“D5:35:33:34:3C:5F”,“rssi”:-64,“brand”:“SwitchBot”,“model”:“Bot”,“model_id”:“X1”,“type”:“ACTR”,“mode”:“onestate”,“state”:“on”,“batt”:100}
…
N: Send on /SYStoMQTT msg {“uptime”:964,“version”:“version_tag”,“disc”:true,“ohdisc”:false,“env”:“esp32dev-ble”,“freemem”:97660,“mqttp”:“1883”,“mqtts”:false,“mqttv”:false,“msgprc”:69,“msgblck”:0,“maxq”:3,“cnt_index”:0,“minmem”:42508,“tempc”:57.78,“freestck”:2236,“eth”:false,“rssi”:-42,“SSID”:“xxxxxxxxx”,“BSSID”:“C8:A7:0A:C9:AA:8E”,“ip”:“192.168.1.15”,“mac”:“C8:2B:96:8C:1F:78”,“lowpowermode”:-1,“modules”:[“WebUI”,“BT”]}
N: Send on /BTtoMQTT msg {“bleconnect”:true,“interval”:55555,“adaptivescan”:true,“intervalacts”:55555,“intervalcnct”:3600000,“scanduration”:10000,“onlysensors”:false,“randommacs”:false,“hasspresence”:false,“prestopic”:“presence/”,“presuseuuid”:false,“minrssi”:-100,“extDecoderEnable”:false,“extDecoderTopic”:“undecoded”,“filterConnectable”:false,“pubadvdata”:false,“pubuuid4topic”:false,“ignoreWBlist”:false,“presenceawaytimer”:120000,“movingtimer”:60000,“forcepscn”:false,“tskstck”:2360,“crstck”:3084,“enabled”:true,“scnct”:15}
N: Send on /WebUItoMQTT msg
(I think here is the point where I did that mosquitto_pub command above)
{“displayMetric”:true,“webUISecure”:true,“displayQueue”:0}
N: BLE Connect begin
Guru Meditation Error: Core 1 panic’ed (Unhandled debug exception).
Debug exception reason: Stack canary watchpoint triggered (imActTask)
Core 1 register dump:
PC : 0x400929d8 PS : 0x00060d36 A0 : 0x80092a76 A1 : 0x3fff6d20
A2 : 0x3ffeba80 A3 : 0x3fff6d70 A4 : 0x00000000 A5 : 0x00000010
A6 : 0x0000000f A7 : 0x0000002b A8 : 0x3fff6d71 A9 : 0x00000044
A10 : 0x00000008 A11 : 0x00000000 A12 : 0x00000000 A13 : 0x3ffba538
A14 : 0xffffffff A15 : 0x353a4333 SAR : 0x00000020 EXCCAUSE: 0x00000001
EXCVADDR: 0x00000000 LBEG : 0x40091d05 LEND : 0x40091d15 LCOUNT : 0xfffffffb
Backtrace: 0x400929d5:0x3fff6d20 0x40092a73:0x3fff6d50 0x401ba701:0x3fff6d70 0x401b43f9:0x3fff7100 0x400f6b3a:0x3fff71c0 0x400e5d0e:0x3fff7210 0x400e616d:0x3fff7950 0x400e677f:0x3fff79b0
ELF file SHA256: 73da1f82e6fd0d79
Rebooting…
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13192
load:0x40080400,len:3028
entry 0x400805e4
N:
************* WELCOME TO OpenMQTTGateway **************
[ 171][E][Preferences.cpp:50] begin(): nvs_open failed: NOT_FOUND
N: SYS config not found
N: OpenMQTTGateway Version: version_tag
N: WiFi ok with manual config credentials
[ 2096][E][Preferences.cpp:50] begin(): nvs_open failed: NOT_FOUND
N: No WebUI config to load
N: OpenMQTTGateway URL: http://192.168.1.15/
N: ZwebUI setup done
[ 3602][E][Preferences.cpp:50] begin(): nvs_open failed: NOT_FOUND
N: BT config not found
N: BLE scans interval: 55555
N: BLE connects interval: 3600000
N: BLE scan duration: 10000
N: Publishing only BLE sensors: false
N: Publishing random MAC devices: false
N: Adaptive BLE scan: true
N: Active BLE scan interval: 55555
N: minrssi: -100
N: Low Power Mode: -1
N: Presence Away Timer: 120000
N: Moving Timer: 60000
N: Force passive scan: false
N: Enabled BLE: true
N: ZgatewayBT multicore ESP32 setup done
N: OpenMQTTGateway modules: [“WebUI”,“BT”]
N: ************** Setup OpenMQTTGateway end **************
W: MQTT connection…
N: Connected to broker
N: Update check, free heap: 98564[ 5790][E][ssl_client.cpp:37] _handle_error(): [start_ssl_client():273]: (-9984) X509 - Certificate verification failed, e.g. CRL, CA or signature check failed
[ 5794][E][WiFiClientSecure.cpp:144] connect(): start_ssl_client: -9984
E: Error on HTTP requestN: Update check done, free heap: 95240N: Send on /SYStoMQTT msg {“uptime”:4,“version”:“version_tag”,“disc”:true,“ohdisc”:false,“env”:“esp32dev-ble”,“freemem”:97692,“mqttp”:“1883”,“mqtts”:false,“mqttv”:false,“msgprc”:0,“msgblck”:0,“maxq”:0,“cnt_index”:0,“minmem”:94116,“tempc”:58.33,“freestck”:5804,“eth”:false,“rssi”:-41,“SSID”:“xxxxxxxx”,“BSSID”:“C8:A7:0A:C9:AA:8E”,“ip”:“192.168.1.15”,“mac”:“C8:2B:96:8C:1F:78”,“lowpowermode”:-1,“modules”:[“WebUI”,“BT”]}
N: Send on /BTtoMQTT msg {“bleconnect”:true,“interval”:55555,“adaptivescan”:true,“intervalacts”:55555,“intervalcnct”:3600000,“scanduration”:10000,“onlysensors”:false,“randommacs”:false,“hasspresence”:false,“prestopic”:“presence/”,“presuseuuid”:false,“minrssi”:-100,“extDecoderEnable”:false,“extDecoderTopic”:“undecoded”,“filterConnectable”:false,“pubadvdata”:false,“pubuuid4topic”:false,“ignoreWBlist”:false,“presenceawaytimer”:120000,“movingtimer”:60000,“forcepscn”:false,“tskstck”:5280,“crstck”:4580,“enabled”:true,“scnct”:0}
N: Send on /WebUItoMQTT msg {“displayMetric”:true,“webUISecure”:true,“displayQueue”:0}
N: Scan begin