I have been unable to connect the example single_thing in the webthing-upy repo. I have a thing gateway on a rpi that I know works. It it as version 0.7. I was able to see an arduino led thing pretty easily.
Now I have a webthing-upy running atop lobo micropython running on an adafruit huzzah32 esp32. My main.py simply just imports ‘start’ and runs ‘start.single()’. I made sure the configure ‘config.py’ with my wifi creds. I copied all of the webthing-upy webthing/.py, upy/.py, and example/*.py into their respective folders onto the device. When I reset the thing device, it boots up and runs main without issue that I can tell.
This is the tail end of the boot/main run:
I (1091) MicroPython: [=== MicroPython FreeRTOS task started (sp=3ffc5c10) ===]
Internal FS (SPIFFS): Mounted on partition ‘internalfs’ [size: 1048576; Flash address: 0x200000]
Filesystem size: 956416 B
Used: 115456 B
Free: 840960 BI (1851) phy: phy_version: 3960, 5211945, Jul 18 2018, 10:40:07, 0, 0
Connecting…
…
ifconfig = (‘192.168.86.250’, ‘255.255.255.0’, ‘192.168.86.1’, ‘192.168.86.1’)
Syncing to NTP…
waiting for time sync…
Time: 2019-02-25 03:44:56
importing single_thing…
Starting single_thing server…
INFO:single_thing:run_server
INFO:server:Registering a single thing
INFO:single_thing:starting the server
INFO:server:Starting Web Server on port 80
MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on ESP32 board with ESP32
Type “help()” for more information.
I made sure that the WebThing Add-on has been enabled. I can see that the ThingURLAdapter is listed in Adapters.
When I try to add the thing, scanning does not discover anything. When I try to add my thing’s URL, http://192.168.xxx.xxx/, it results in “web thing not found”.
Here is a snippet of what I see in the developer’s log:
2019-02-25 04:18:12.897 INFO : About to call startPairing on ThingURLAdapter
2019-02-25 04:18:12.911 INFO : Opened a new things socket
2019-02-25 04:18:46.165 INFO : thing-url: Failed to parse description at http://esp32-upy-f1efc0.local:80: SyntaxError: Unexpected token < in JSON at position 8
2019-02-25 04:19:12.906 INFO : Pairing timeout
2019-02-25 04:19:12.909 ERROR : Thing was not added
2019-02-25 04:19:12.910 ERROR : addNewThing cancelled
2019-02-25 04:19:12.914 INFO : thing-url: Adapter: ThingURLAdapter id thing-url-adapter pairing cancelled
2019-02-25 04:19:41.139 INFO : Tunnel domain found. Tunnel name is: mysubdomain and tunnel domain is: mozilla-iot.org
2019-02-25 04:19:41.144 INFO : Tunnel name is set to: https://mysubdomain.mozilla-iot.org
2019-02-25 04:19:41.145 INFO : Local mDNS Service Domain Name is: gateway
2019-02-25 04:19:49.525 INFO : About to call startPairing on ThingURLAdapter
2019-02-25 04:19:49.857 INFO : thing-url: Failed to parse description at http://esp32-upy-f1efc0.local:80: SyntaxError: Unexpected token < in JSON at position 8
2019-02-25 04:19:49.866 INFO : Opened a new things socket
2019-02-25 04:20:49.533 INFO : Pairing timeout
2019-02-25 04:20:49.536 ERROR : Thing was not added
2019-02-25 04:20:49.539 ERROR : addNewThing cancelled
2019-02-25 04:20:49.543 INFO : thing-url: Adapter: ThingURLAdapter id thing-url-adapter pairing cancelled
I see the JSON parse error above. I am not sure what description it is looking at. I examined the ‘description’ properties in single_thing.py and they all looked like valid JSON.
I installed zeroconf and ran the code to browse for a webthing service. Here’s what I got:
browser = ServiceBrowser(zeroconf, ‘_webthing._tcp.local.’, listener)
Service esp32-upy-f1efc0._webthing._tcp.local. added, service info ServiceInfo(type=‘_webthing._tcp.local.’, name=‘esp32-upy-f1efc0._webthing._tcp.local.’, address=b’\xc0\xa8V\xfa’, port=80, weight=0, priority=0, server=‘esp32-upy-f1efc0.local.’, properties={b’board’: b’ESP32’, b’path’: b’/'})
I’m guessing that the mDNS logic in webthing/server.py is working as designed given the output above.
Any ideas what I might be doing wrong here?
Thanks
Gary