pdf-icon

UIFlow Guide

UIFlow 1.0 Blockly

Event

Unit

UIFlow 1.0 Project

Module IoT Base Catm

API

catmiot.get_gprs_network_registration()
  • Check if the device is registered in the GPRS network
catmiot.get_network_registration()
  • Check if the device is registered in a regular network
catmiot.get_single_quality()
  • Check the current signal quality of the device
catmiot.check_status()
  • Check the status of the module to see if it is functioning properly
catmiot.delete_coap()
  • Send a DELETE request in the CoAP protocol to delete resources on the server
catmiot.coap_request('/m5stack-get')
  • Send a GET request in the CoAP protocol to retrieve resources from the specified URL
    • /m5stack-get: The specified URL path to retrieve resources from
catmiot.coap_to_connect('120.77.157.90', 5683)
  • Initialize the connection to the specified IP address and port for CoAP communication
    • IP: 120.77.157.90
    • Port: 5683
catmiot.coap_request('/m5stack-post', 2, '')
  • Send a POST request via CoAP protocol to the specified URL
    • URL: /m5stack-post
    • Payload: Data payload to send.
catmiot.power_save_mode(0, 0, 0, 0, False)
  • Disable power-saving mode to ensure the device operates continuously at high performance
catmiot.disconnect_server()
  • Disconnect the device from the HTTP server
catmiot.enable_PDP_context()
  • Enable PDP context, commonly used for GPRS or LTE network communication, ensuring the establishment of the data transmission context
catmiot.get_ezdata(ezdata_get_kslNzcb, 'GCJ3Ic5h2eXnzV3rT3bBXvrncCaJnART', '')
  • Retrieve data from a specified topic
    • Token: dCtdfg3u5id72J8YCubqu16zMqQunDQh
catmiot.remove_ezdata('GCJ3Ic5h2eXnzV3rT3bBXvrncCaJnART', '')
  • Delete the specified topic from the remote server
    • Token: dCtdfg3u5id72J8YCubqu16zMqQunDQh
catmiot.set_ezdata('GCJ3Ic5h2eXnzV3rT3bBXvrncCaJnART', '', '', 0)
  • Save data to the specified topic and authenticate with the provided token
    • Token: dCtdfg3u5id72J8YCubqu16zMqQunDQh
    • Mode: Single (indicates the data saving mode is for single data)
    • Data: The data to be saved.
catmiot.get_CCID()
  • Retrieve the CCID (Integrated Circuit Card Identifier) of the current SIM card, which is the unique identifier of the SIM card
catmiot.get_IMEI()
  • Retrieve the IMEI (International Mobile Equipment Identity) of the device, which is the unique identifier of the device
catmiot.gprs_service(1)
  • Set or check the GPRS service status of the device. This sets it to ACTIVE, meaning GPRS service is enabled
catmiot.http_service(1, '', '', {}, '')
  • Use the HTTP protocol to send a GET request and retrieve data from a remote server
    • Method: GET (HTTP request method)
    • URL: The request address
    • Headers: Create a map containing HTTP request header information
    • Payload: Data can be passed through this parameter if it's a POST request.
catmiot.init_modem(True)
  • Power on and initialize the module, preparing for subsequent communication and data interaction
catmiot.modbus_init(15, 13, 115200, 1, 1)
  • Initialize the UART communication interface, set TX (transmit) pin to 15, RX (receive) pin to 13, baud rate to 115200, mode to master, and the slave device address to 1

<img class="blockly_svg" src=" https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/uiflow/block

ly/modules/iot_base_catm/uiflow_block_iotbasecatm_modbus_master_u_read_coils.svg">

modbus.read_coils(1, 1, 0)
  • Read the coil status from slave device address 1, starting at address 1, and reading 0 coils
modbus.read_discrete_inputs(1, 1, 0)
  • Read the discrete input status from slave device address 1, starting at address 1, and reading 0 inputs
modbus.read_holding_registers(1, 1, 0, True)
  • Read the holding register data from slave device address 1, starting at address 1, and reading 0 registers, with the data being signed
modbus.read_input_registers(1, 1, 0, True)
  • Read the input register data from slave device address 1, starting at address 1, and reading 0 registers, with the data being signed
modbus.write_multiple_coils(1, 1, 0)
  • Write data to multiple coils in slave device address 1, starting at address 1, writing the output value of 0
modbus.write_multiple_registers(1, 1, 0, True)
  • Write data to multiple registers in slave device address 1, starting at address 1, writing the register value of 0, with the data being signed
modbus.write_single_coil(1, 1, 0)
  • Write a value to a single coil in slave device address 1, with the output address being 1 and the value being 0
modbus.write_single_register(1, 1, 0, True)
  • Write data to a single register in slave device address 1, with the register address being 1 and the value being 0, with the data being signed
1~6,15,16
  • Set the MODBUS function code to READ_COILS_STATUS, used to read the status of coils
modbus.find_address
  • Get the slave device address in the current MODBUS communication
modbus.find_function
  • Get the function code of the current MODBUS operation
modbus.find_quantity
  • Get the quantity value to be read or written in the current MODBUS request
modbus.function_init(1, 0, 0)
  • Initialize the MODBUS slave function code to READ_COILS_STATUS, used to read the status of coils from the specified start address and quantity
modbus.receive_req_create_pdu()
  • Receive the ADU (Application Data Unit) request, indicating that the request data from the master device has been received
modbus.create_slave_response(1)
  • Send the ADU response data buffer to respond to the master device’s request
modbus.update_process(1, 0, 0, [0, 0, 0])
  • Update the READ_COILS_STATUS function, reading the specified quantity of coils starting from the starting address and returning the corresponding data list
catmiot.mqtt_ischeck_connect()
  • Check the connection status of the MQTT server
catmiot.mqtt_to_connect('mqtt.m5stack.com', 1883, '', '', '', 120)
  • Initialize the MQTT server connection, setting the server address, port, client ID, username, password, and keep-alive time
catmiot.mqtt_disconnect()
  • Disconnect from the MQTT server
catmiot.mqtt_poll()
  • Poll for downlink messages and check if the MQTT server has sent new messages to the device
catmiot.mqtt_publish('', '', 0)
  • Publish a message to a specified MQTT topic, including the message content (payload) and QoS (Quality of Service) settings

<img class="blockly_svg" src=" https://m5stack.oss-cn-shenzhen.aliyuncs.com/resource/docs/static/assets/img/uiflow/blockly/modules/iot_base_catm/uiflow_block_iotbasecatm_mqtt

_sub.svg">

catmiot.mqtt_subscribe('', iotbasecatm_mqtt_cb, 0)
  • Subscribe to the specified MQTT topic and set the QoS (Quality of Service) level
def iotbasecatm_mqtt_cb(catm_mq_topic, catm_mq_payload):
  global ezdata_value1, catm_topic, catm_msg
  catm_topic = catm_mq_topic
  catm_msg = catm_mq_payload
  pass
  • Set the callback function for when an MQTT topic subscription message is received, handling the received topic message
catmiot.mqtt_unsubscribe('')
  • Unsubscribe from the specified MQTT topic
catmiot.network_active(0, 1)
  • Activate the specified network ID and set the network action to active
catmiot.get_network_ip(0)
  • Retrieve the IP address of the specified network
catmiot.poweroff()
  • Power off the module
catmiot.power_save_mode(0, 10, 0, 5)
  • Enable power-saving mode and set the periodic TAU (time interval) and active time period
    • Periodic-TAU: Set in 10-minute intervals, 10 means a wake-up interval of 10 x 10 minutes, or 100 minutes. 
    • Active Time: Set in 2-second intervals, 5 means the device will remain active for 10 seconds after waking up.
catmiot.set_command_echo_mode(0)
  • Set the command echo mode to OFF, disabling command echo
catmiot.show_PDP_address()
  • Display the PDP (Packet Data Protocol) address, typically used to show the device's network connection status
modbus._mdbus_uart.any()
  • Check if there is data remaining in the UART buffer
modbus._mdbus_uart.read()
  • Read all available data from the UART
modbus._mdbus_uart.readline()
  • Read a line of data from the UART until a newline character is encountered (typically \n)
modbus._mdbus_uart.read(10)
  • Read a specified number of characters from the UART, set to read 10 characters here
modbus._mdbus_uart.write('')
  • Write the specified data to the UART
modbus._mdbus_uart.write(''+"\r\n")
  • Write a line of data to the UART, typically with a newline character (\n) attached
modbus._mdbus_uart.write(bytes([0, 0, 0]))
  • Write a raw data list to the UART
    • A list is created here containing three values 0, 0, 0, indicating that these values will be sent via UART.
On This Page