Skip to content

Commit c868cbf

Browse files
committed
Quectel stuff
1 parent 7dba2cd commit c868cbf

File tree

5 files changed

+1661
-1
lines changed

5 files changed

+1661
-1
lines changed

Examples/ex06_LE910Q1.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Under Active Development - INCOMPLETE!"""
2+
3+
# import dashio
4+
from dashio import telit_LE910Q1
5+
import time
6+
import logging
7+
from dashio.iotcontrol.enums import ConnectionState
8+
9+
10+
logging.getLogger('dashio').setLevel(logging.DEBUG)
11+
12+
formatter = logging.Formatter("[%(asctime)s][%(module)15s] -- %(message)s")
13+
handler = logging.StreamHandler()
14+
handler.setFormatter(formatter)
15+
logger = logging.getLogger()
16+
logger.addHandler(handler)
17+
logger.setLevel(logging.DEBUG)
18+
19+
20+
def _on_mqtt_connect(connected: bool, error_state: telit_LE910Q1.ErrorState):
21+
if connected:
22+
logger.debug("MQTT connected OK")
23+
24+
time.sleep(5) # ???
25+
control_topic = "craig/TELIT_DEVICE_ID/control"
26+
lte.subscribe(control_topic)
27+
else:
28+
logger.debug("MQTT disconnecting reason %s", error_state)
29+
30+
31+
def _on_mqtt_subscribe(topic: str, error: int):
32+
logger.debug("Subscribed: %s %s", topic, str(error))
33+
34+
announce_topic = "craig/TELIT_DEVICE_ID/announce"
35+
announce_message = "\tTELIT_DEVICE_ID\tWHO\tTelit_TYPE\tTelit_Test\n"
36+
lte.publish_message(announce_topic, announce_message)
37+
38+
39+
def _on_mqtt_receive_message(message: str):
40+
try:
41+
logger.debug("LTE Rx ←\n%s\n", message.rstrip())
42+
except UnicodeDecodeError:
43+
logger.debug("LTE SERIAL DECODE ERROR Rx:\n%s\n", message)
44+
45+
46+
lte = telit_LE910Q1.LE910Q1("/dev/cu.usbmodem1103", "", "iot.gdsp.nz", 115200)
47+
lte.mqtt_setup("dash.dashio.io", 8883, "craig", "ThingyThing")
48+
lte.set_callbacks(_on_mqtt_connect, _on_mqtt_subscribe, _on_mqtt_receive_message)
49+
lte._will_topic = "craig/TELIT_DEVICE_ID/data"
50+
lte.run()
51+
52+
while True:
53+
time.sleep(1)

Examples/ex07_EG800Q.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Under Active Development - INCOMPLETE!"""
2+
3+
# import dashio
4+
from dashio import quectel_EG800Q
5+
import time
6+
import logging
7+
from dashio.iotcontrol.enums import ConnectionState
8+
9+
10+
logging.getLogger('dashio').setLevel(logging.DEBUG)
11+
12+
formatter = logging.Formatter("[%(asctime)s][%(module)15s] -- %(message)s")
13+
handler = logging.StreamHandler()
14+
handler.setFormatter(formatter)
15+
logger = logging.getLogger()
16+
logger.addHandler(handler)
17+
logger.setLevel(logging.DEBUG)
18+
19+
20+
def _on_mqtt_connect(connected: bool, error_state: quectel_EG800Q.ErrorState):
21+
if connected:
22+
logger.debug("MQTT connected OK")
23+
24+
time.sleep(5) # ???
25+
control_topic = "craig/QUECTEL_DEVICE_ID/control"
26+
lte.subscribe(control_topic)
27+
else:
28+
logger.debug("MQTT disconnecting reason %s", error_state)
29+
30+
31+
def _on_mqtt_subscribe(topic: str, error: int):
32+
logger.debug("Subscribed: %s %s", topic, str(error))
33+
34+
announce_topic = "craig/QUECTEL_DEVICE_ID/announce"
35+
announce_message = "\tQUECTEL_DEVICE_ID\tWHO\tQuectel_TYPE\tQuectel_Test\n"
36+
lte.publish_message(announce_topic, announce_message)
37+
38+
39+
def _on_mqtt_receive_message(message: str):
40+
try:
41+
logger.debug("LTE Rx ←\n%s\n", message.rstrip())
42+
except UnicodeDecodeError:
43+
logger.debug("LTE SERIAL DECODE ERROR Rx:\n%s\n", message)
44+
45+
46+
lte = quectel_EG800Q.EG800Q("/dev/cu.usbmodem1103", "", "iot.gdsp.nz", 115200)
47+
lte.mqtt_setup("dash.dashio.io", 8883, "craig", "ThingyThing")
48+
lte.set_callbacks(_on_mqtt_connect, _on_mqtt_subscribe, _on_mqtt_receive_message)
49+
lte._will_topic = "craig/QUECTEL_DEVICE_ID/data"
50+
lte.run()
51+
52+
while True:
53+
time.sleep(1)

dashio/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
from .schedular import Schedular
7676
from .tcp_connection import TCPConnection
7777
from .zmq_connection import ZMQConnection
78+
from . import quectel_EG800Q
7879

7980
__all__ = [
8081
'Device',
@@ -144,7 +145,8 @@
144145
'ButtonGroup',
145146
'EventData',
146147
'EventLog',
147-
'ColorPicker'
148+
'ColorPicker',
149+
'quectel_EG800Q'
148150
]
149151

150152

0 commit comments

Comments
 (0)