FiPy not connecting to MQTT with LTE CatM1
I am having trouble getting the FiPy to send messages via LTE Cat-M1. I have update the sequans, and the latest firmware for the FiPy.
According to lte.isattached and lte.isconnected everything is True.
When connecting by Wifi the MQTT message send no problems.
I have checked to make sure I have data on the SIM.
The code I have eventually returns:
Traceback (most recent call last): File "main.py", line 42, in <module> File "mqtt.py", line 84, in connect IndexError: bytes index out of range
import machine import network import os import time import socket import ssl import pycom from network import LTE from mqtt import MQTTClient def sub_cb(topic, msg): print(msg) # setup as a station lte = LTE() print("Line 15") lte.send_at_cmd('AT+CFUN=0') lte.send_at_cmd('AT!="clearscanconfig"') lte.send_at_cmd('AT!="addscanfreq band=28 dl-earfcn=9410"') lte.send_at_cmd('AT+CGDCONT=1, "IP", "telstra.internet"') lte.send_at_cmd('AT+CEMODE=0') lte.send_at_cmd('AT+CEREG=2') lte.send_at_cmd('AT+CFUN=1') while not lte.isattached(): print("Attaching...") time.sleep(0.1) print("Attached") lte.connect() while not lte.isconnected(): print("Connecting...") time.sleep(0.1) print("Connected!") time.sleep(2) print(lte.isconnected()) client = MQTTClient("Demo","io.adafruit.com",user="Dylan", password="xxxx", port=1883) print("Line 38") print(lte.isconnected()) client.set_callback(sub_cb) print("Line 41") client.connect() print("Line 43") time.sleep(3) client.subscribe(topic="Dylan/feeds/mqtt") print("Line 46") while True: print("Sending ON") client.publish(topic="Dylan/feeds/mqtt", msg="ON") print("Line 51") time.sleep(1) print("Sending OFF") client.publish(topic="Dylan/feeds/mqtt", msg="OFF") print("Line 55") client.check_msg() time.sleep(1)
Any help would be greatly appreciated,
@dylan Hi Dylan. I am using MQTT constantlty over CAT-M1 on Telstra.
I am only using.
lte.send_at_cmd('AT+CGDCONT=1,"IP","telstra.internet"') lte.send_at_cmd("AT!=\"RRC::addscanfreq band=28 dl-earfcn=9410\"") lte.send_at_cmd('AT+CFUN=1')
And have not had to resort to the additional AT commands you are using.
I have also found the reset the modem if I have lost the connection and am reconnecting without a power cycle.
Other than that its working very reliably for me.
I am not using
mqttbut using the AWS client (not to connect to AWS) as I need TLS with certificate support.
We use Losant. They do support port 1883.
@jmarcelino Gave the same error :(
jmarcelino last edited by
after line 55
self.sock = socket.socket()