Checking bandwidth available for FiPy possible?



  • Hi.

    Would have posted in the "Cellular" topic, but that is unavailable.

    I am using a FiPy, which is used for sending sensor data to Azure IoT Hub using LTE NB-IoT. But i am finding that establishing the connection to Azure takes a long time, sometimes up to around 10 seconds.

    Due to power-saving reasons, i don't want it to stay connected all the time, but the wait for connecting to Azure is not optimal.

    I would like to investigate the bandwidth that we are operating with when using the LTE NB-IoT network. Is there a method that can do this in the network library?

    Is the network library available for reading?

    Best Regards
    RM



  • So my bandwidth is not really the problem here. The problem is that the umqtt / simple library is slow in use. When my FiPy is already connected to LTE, and it then tries to connect to Azure IoT Hub, establishing the connection takes around 30 seconds, whereas simply publishing is fast and not a issue at all. So i am currently looking into optimizing / speeding up the connect routine if possible in the simple.py library.

    Here is the code i use to connect:

    def iot_connect(self):
            if self.IoTConnectedFlag == False:
                self.password = self.generate_sas_token(self.uri, self.primary_key, self.policy_name)
                beforeConn = utime.ticks_us()
                self.username_fmt = "{}/{}/api-version=2018-06-30"
                self.username = self.username_fmt.format(self.hostname, self.device_id)
                self.client = MQTTClient(client_id=self.device_id, server=self.hostname, port=8883, user=self.username, password=self.password, keepalive=4000, ssl=True)
                self.client.connect()
                print("IoT Connected!")
                self.IoTConnectedFlag = True
                afterConn = utime.ticks_us()
                connDone = afterConn - beforeConn
                print(connDone)
    

    the utime.ticks_us() are used to observe how long time the method takes to execute.

    • Whole method = 28.61 secs

    • Whole method minus SAS Token generation = 27.27 secs

    • self.client.connect() = 16.94 secs

    Any ideas on how to optimize this speed is very welcome! Thanks

    /RM



  • Found the solution! Posting here anyone who would ask the same:

    print(lte.send_at_cmd('AT+CSQ'))
    print(lte.send_at_cmd('AT+CSQ=?'))
    

    This will show you the signal quality, and the number of errors!

    /RM


Log in to reply
 

Pycom on Twitter