pybytes.connect() hangs in _pybytes.py, line 128, in send_info_message (using NB-IoT with gpy on Orange network Belgium)
jand last edited by
I am able to connect and send data with pybytes. But when testing how reliable it is in a measurement cycle when the gpy goes in deepsleep (using pybytes.deepsleep(ms)), it turns out that some of the steps in pybytes.connect() can take a very long time (a minute or more). In particular, the pybytes.connect() step at times gets stuck at the end (after the LTE connection is established and the device is connected to MQTT mqtt.pybytes.pycom.io).
This is the test code I am using:
from machine import RTC import time, machine, pycom from _pybytes_config import PybytesConfig pybytes_config = PybytesConfig().read_config() from _pybytes import Pybytes start=time.ticks_ms() print('Starting pybytes...') pybytes=Pybytes(pybytes_config) print('This took ', time.ticks_diff(time.ticks_ms(),start)/1000,' s') start=time.ticks_ms() print('Doing pybytes.connect()...') pybytes.connect() print('This took ', time.ticks_diff(time.ticks_ms(),start)/1000,' s')
And this is the output (after waiting for several minutes I had to interrupt it with CTRL+C):
>>> Starting pybytes... WMAC: 30AEA42A5B54 Firmware: 1.20.1.r2 Pybytes: 1.3.0 This took 0.924 s Doing pybytes.connect()... Initialized watchdog for WiFi and LTE connection with timeout 1260000 ms LTE connection established Connected to MQTT mqtt.pybytes.pycom.io Pybytes connected successfully (using the built-in pybytes library) Unhandled exception in thread started by <bound_method> Traceback (most recent call last): File "_msg_handl.py", line 260, in _io_thread_func KeyboardInterrupt: ╝Traceback (most recent call last): File "<stdin>", line 15, in <module> File "_pybytes.py", line 265, in connect File "_pybytes.py", line 257, in connect File "_pybytes.py", line 128, in send_info_message File "_pybytes_protocol.py", line 413, in send_info_message File "_pybytes_protocol.py", line 396, in __send_message File "_pybytes_protocol.py", line 378, in __send_message File "_mqtt.py", line 139, in publish File "_msg_handl.py", line 260, in _io_thread_func KeyboardInterrupt:
This problem seems to happen in the following code at the moment when self.send_info_message() is executed in _pybytes.py Line 254 (code found on /pybytes-master/esp32/frozen/Base/_pybytes_protocol.py):
def send_info_message(self): try: releaseVersion = self.__conf['application']['release']['version'] except: releaseVersion = None self.__send_message(self.__pybytes_library.pack_info_message(releaseVersion))
What is the problem? And how to avoid this? And what is the script actually trying to do at this point? The connection is already established and data can be send at this point (using pybytes.send_signal()).
The trouble is that there is very little documentation available on the pybytes functions. And if establishing the LTE connection can not be done repeatedly in a reliable way, this will not work in a measurement cycle that has to run for months on a battery.