Initialize the TX and RX pins for the LTE module.
Print the module status, signal quality, network registration status, and GPRS network registration status.
In the main loop, check the GPRS network registration status, and if registration is successful, execute an HTTP GET request to access
http://www.m2msupport.net/m2msupport/test.php
, retrieve data from the response, and print the results.
from m5stack import *
from m5stack_ui import *
from uiflow import *
from comx.lte import LTE
screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
resp = None
lte = LTE(tx=13, rx=5)
print(lte.check_status())
print(lte.get_single_quality())
print(lte.get_network_registration())
print(lte.get_gprs_network_registration())
while True:
if str((lte.get_gprs_network_registration())) == '1':
# echo "test"
resp = lte.http_get('http://www.m2msupport.net/m2msupport/test.php')
if resp:
print(resp[1])
wait_ms(2)
Initialize the TX and RX pins for the LTE module.
Print the module status, signal quality, network registration status, and GPRS network registration status.
In the main loop, check the GPRS network registration status, and if registration is successful, create a dictionary containing a random integer, convert it to JSON format, and send it via an HTTP POST request to http://httpbin.org/post
, then parse the response, extract the data, and print the results.
from m5stack import *
from m5stack_ui import *
from uiflow import *
from comx.lte import LTE
import json
screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
resp = None
post_data = None
import random
lte = LTE(tx=13, rx=5)
print(lte.check_status())
print(lte.get_single_quality())
print(lte.get_network_registration())
print(lte.get_gprs_network_registration())
while True:
if str((lte.get_gprs_network_registration())) == '1':
post_data = {'random1':random.randint(0, 100)}
resp = lte.http_post('http://httpbin.org/post', 'application/json', str((json.dumps(post_data))))
if resp:
print((json.loads(resp[1]))['data'])
wait_ms(2)
lte.get_gprs_network_registration()
lte.get_network_registration()
lte.get_single_quality()
lte.check_status()
lte.enable_PDP_context()
lte.http_get('')
lte.http_post('', 'application/json', '')
lte.http_terminate()
LTE(tx=13, rx=5)
lte.poweroff()
lte.reset()
lte.set_command_echo_mode(0)