pdf-icon

EzData

功能说明

EzData is an IoT cloud data storage service provided by M5Stack, allowing different devices to insert or retrieve data into a storage queue using a unique token, enabling data sharing across devices.

Example

from m5stack import *
from m5ui import *
from uiflow import *
from flow import ezdata
import wifiCfg

i = None

wifiCfg.autoConnect(lcdShow=False)

while True:
  ezdata.setData('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_topic', 'Hello EzData')
  print(ezdata.getData('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_topic'))
  for i in range(11):
    ezdata.addToList('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_list', i)
  print(ezdata.getData('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_list', 0, 50))
  ezdata.removeData('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_topic')
  print(ezdata.getCurrentISODateTime())
  wait_ms(2)
ezdata.setData('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_topic', 'Hello EzData')
  • Save Data to the Head of a Specified Topic Queue
print(ezdata.getData('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_topic'))
  • Retrieve a Data Item from the Head of a Specified Topic Queue
ezdata.addToList('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_list', i)
  • Save Data to the Head of a Specified Data List
print(ezdata.getData('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_list', 0, 50))
  • Retrieve a Set of Data from a Specified Data List, with the advantage of list storage being able to specify an offset from the head of the list and retrieve multiple data items at once. Parameters include:
  • list: Name of the list (string)
  • offset: Offset from the head of the list
  • count: Number of data items to retrieve
ezdata.removeData('6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_topic')
  • Delete a Topic or List and Clear Queue Data
print(ezdata.getCurrentISODateTime())
  • Get Current ISO Date and Time
ezdata.setDataAsync(ezdata_set_NdmNNcb, ezdata_set_fail_NdmNNcb, '6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_topic', 'Hello EzData')
  • Asynchronous Operation: Save data to the head of a specified topic queue
ezdata.addToListAsync(ezdata_set_iQCwDcb, ezdata_set_fail_iQCwDcb, '6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_list', i)
  • Asynchronous Operation: Save data to the head of a specified data list
ezdata.getDataAsync(ezdata_get_iRBYXcb, ezdata_get_fail_iRBYXcb, '6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_topic')
  • Asynchronous Operation: Retrieve a data item from the head of a specified topic queue
ezdata.getDataAsync(ezdata_get_rfWJMcb, ezdata_get_fail_rfWJMcb, '6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', 'my_list', 0, 50)
  • Asynchronous Operation
  • Retrieve a Set of Data from a Specified Data List, with the advantage of list storage being able to specify an offset from the head of the list and retrieve multiple data items at once. Parameters include:
  • list: Name of the list (string)
  • offset: Offset from the head of the list
  • count: Number of data items to retrieve
ezdata.removeDataAsync(ezdata_remove_KcMAbcb, ezdata_remove_fail_KcMAbcb, '6ijRMmiFRdO2tVfFIbNpy6PN1sRvFmsy', '')
  • Asynchronous Operation: Delete a topic or list and clear queue data
ezdata.getCurrentISODateTimeAsync(ezdata_get_ESdHGcb, ezdata_get_fail_ESdHGcb)
  • Asynchronous Operation: Get current ISO date and time
Notes:
1. All operations above rely on a unique token, which remains fixed within the same browser environment. Please copy the token before use.
2.If no data operations are performed within six months, the data queue corresponding to that token will be emptied.
3. Data is sorted in descending order based on insertion time (with the last inserted data at the head of the list), and data accumulates over time.

使用案例

保存数据

This program demonstrates how to save data to a specified topic and save data to a specified data list.

获取数据

This program demonstrates how to retrieve data from a specified topic, retrieve multiple data items from a data list at once, and clear the queue.

Run these programs separately on two M5 devices, triggering data saving and retrieval via buttons.

On This Page