pybytes.connect() hangs in, line 128, in send_info_message (using NB-IoT with gpy on Orange network Belgium)

  • 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

    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
    print('Starting pybytes...')
    print('This took ', time.ticks_diff(time.ticks_ms(),start)/1000,' s')
    print('Doing 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
    Pybytes connected successfully (using the built-in pybytes library)
    Unhandled exception in thread started by <bound_method>
    Traceback (most recent call last):
      File "", line 260, in _io_thread_func
    ╝Traceback (most recent call last):
      File "<stdin>", line 15, in <module>
      File "", line 265, in connect
      File "", line 257, in connect
      File "", line 128, in send_info_message
      File "", line 413, in send_info_message
      File "", line 396, in __send_message
      File "", line 378, in __send_message
      File "", line 139, in publish
      File "", line 260, in _io_thread_func

    This problem seems to happen in the following code at the moment when self.send_info_message() is executed in Line 254 (code found on /pybytes-master/esp32/frozen/Base/

    def send_info_message(self):
                releaseVersion = self.__conf['application']['release']['version']
                releaseVersion = None

    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.

Log in to reply

Pycom on Twitter