
UiFlow 使用教程
通过 NB-IoT 模块连接到指定的 CoAP 服务器 IP 地址 120.77.157.90,端口 5683,并依次发送 GET 请求、带有 post-test 数据的 POST 请求,以及带有 put-test 数据的 PUT 请求,均采用纯文本格式传输数据
from m5stack import *
from m5ui import *
from uiflow import *
from comx.nbiot import NBIoT
setScreenColor(0x222222)
nb = NBIoT(tx=13, rx=5)
if nb.coap_connect('120.77.157.90', 5683):
print(nb.coap_get('/m5stack-get'))
print(nb.coap_post('/m5stack-post', 'post-test', content_format=0))
print(nb.coap_put('/m5stack-put', 'put-test', content_format=0)) nb.get_gprs_network_registration() nb.get_network_registration() nb.get_single_quality() nb.check_status() nb.coap_connect('', 5683) nb.coap_destroy() nb.coap_get('') nb.coap_post('', '', content_format=0) nb.coap_put('', '', content_format=0) NBIoT(tx=13, rx=5) nb.mqtt_check_connection() nb.mqtt_connect('', 1883, '', '', '', 0) nb.mqtt_disconnect() nb.mqtt_poll() nb.mqtt_publish('', '', 0) nb.mqtt_subscribe('', nbiot_mqtt_cb, 0) def nbiot_mqtt_cb(nb_mq_topic, nb_mq_payload):
global nb_topic, nb_msg, nb
nb_topic = nb_mq_topic
nb_msg = nb_mq_payload
pass nb.mqtt_unsubscribe('') nb.poweroff() nb.reset() nb.set_command_echo_mode(0)