Hello,
I have been working on this for a while and now I am stumped. I tried to figure it out on my own but now I am in need of assistance. I am trying to connect up my PicoLTE to a HiveMQ Cloud MQTT broker but get error messages.
Here is the code:
import time
from pico_lte.core import PicoLTE
from pico_lte.common import debug
from pico_lte.utils.status import Status
debug.set_level(0)
picoLTE = PicoLTE()
picoLTE.network.register_network()
picoLTE.network.get_pdp_ready()
debug.info(“Opening Connection”)
picoLTE.mqtt.open_connection()
debug.info(“Connecting to broker”)
picoLTE.mqtt.connect_broker()
debug.info(“Subscribing”)
picoLTE.mqtt.subscribe_topics()
debug.info(“Publishing Message to topics…”)
#first_time = time.time()
while True:
result = picoLTE.mqtt.read_messages()
print(result[“messages”])
time.sleep(5)
Here is the config:
{
“mqtts”:{
“host”:“62…15e2.s2.eu.hivemq.cloud”,
“port”: 8883,
“client_id”: “USERNAME”,
“username”:“USERNAME”,
“password”:“PASSWORD”,
“sub_topics”: [
[“gate/opener”, 0],
]
}
}
Here is the shell output:
DEBUG: Power status: 0
DEBUG: Power status: 0
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: COM: {‘response’: [‘OK’], ‘status’: 0}
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Response: [‘\r\n+CREG: 0,5\r\n\r\nOK\r\n’]
DEBUG: Processed: [‘+CREG: 0,5’, ‘OK’]
DEBUG: Desired: +CREG: 0,5
DEBUG: check_network_registration : {‘response’: [‘+CREG: 0,5’, ‘OK’], ‘status’: 0}
DEBUG: success : {‘response’: [‘+CREG: 0,5’, ‘OK’], ‘status’: 0}
DEBUG: Response: [‘\r\n+CGACT: 1,1\r\n+CGACT: 2,0\r\n\r\nOK\r\n’]
DEBUG: Processed: [‘+CGACT: 1,1’, ‘+CGACT: 2,0’, ‘OK’]
DEBUG: Desired: +CGACT: 1,1
DEBUG: check_pdp_context_status : {‘response’: [‘+CGACT: 1,1’, ‘+CGACT: 2,0’, ‘OK’], ‘status’: 0}
DEBUG: success : {‘response’: [‘+CGACT: 1,1’, ‘+CGACT: 2,0’, ‘OK’], ‘status’: 0}
INFO: Opening Connection
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Processed: [‘+QMTOPEN: 0,0’]
INFO: Connecting to broker
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Processed: [‘+QMTSTAT: 0,1’]
INFO: Subscribing
DEBUG: Response: [‘\r\nERROR\r\n’]
DEBUG: Processed: [‘ERROR’]
INFO: Publishing Message to topics…
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
DEBUG: Response: [‘\r\nOK\r\n’]
DEBUG: Processed: [‘OK’]
No matter what I send to gate/ or gate/opener, no messages are recieved.
I know the code is super primitive, I kept messing with it, stripping it down, adding more in etc…