How to publish a table using JSON format to MQTT server in DolphinDB

hz.wale

I want to publish a table using JSON format,the table is defined as below,

COLS_READINGS   = `time`device_id`battery_level`battery_status`battery_temperature`bssid`cpu_avg_1min`cpu_avg_5min`cpu_avg_15min`mem_free`mem_used`rssi`ssid
TYPES_READINGS  = `DATETIME`SYMBOL`INT`SYMBOL`DOUBLE`SYMBOL`DOUBLE`DOUBLE`DOUBLE`LONG`LONG`SHORT`SYMBOL
schema_readings = table(COLS_READINGS, TYPES_READINGS)

Then what should I do? Does dolphindb support mqtt publish,Or can I write a plugin myself with mosquitto?

smile qian

DolphinDB has a mqtt client plugin that can be downloaded from https://github.com/dolphindb/DolphinDBPlugin/tree/master/mqtt.

loadPlugin("PluginMQTTClient.txt"); 
use mqtt; 

//***************************publish a table****************************************//
MyFormat = take("", 5)
MyFormat[2] = "0.000"
f = createCsvFormatter(MyFormat, ',', ';')

//create a record for every device
def writeData(hardwareVector){
  hardwareNumber = size(hardwareVector)
  return table(take(hardwareVector,hardwareNumber) as hardwareId ,take(now(),
    hardwareNumber) as ts,rand(20..41,hardwareNumber) as temperature,
    rand(50,hardwareNumber) as humidity,rand(500..1000,
    hardwareNumber) as voltage)
 }
def publishTableData(server,topic,iterations,hardwareVector,interval,f){
 conn=connect(server,1883,0,f,100)
 for(i in 0:iterations){
   t=writeData(hardwareVector)
   publish(conn,topic,t)
   sleep(interval)
 }
 close(conn)

}
host="192.168.1.201"
submitJob("submit_pub1", "submit_p1", 
publishTableData{host,"sensor/s001",10,100..149,100,f})
publishTableData(host,"sensor/s001",100,0..99,100,f)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to publish a table in dolphinDB?

From Dev

How to publish data to using MQTT

From Dev

How to publish json data on mqtt broker in python?

From Dev

How to ungroup a table in DolphinDB?

From Dev

How to check if a shared table exists using DolphinDB Python API?

From Dev

Is it possible to publish a file into MQTT server?

From

How to format a JSON string as a table using jq?

From Dev

How to format a JSON string as a table using jq?

From Dev

How to show json data in a table format retrieved from node.js server using Angular Js

From Dev

how to publish MQTT messages concurrently using java client?

From Dev

How to generate a random values periodically and publish it using MQTT protocol?

From Java

How to implement MQTT server using Spring Integration?

From Dev

How to format/customize data in table columns using datatables server processing?

From Dev

How to remove duplication row from dolphindb table?

From Dev

How to convert a list of dictionary to a table in DolphinDB

From Dev

How to remove the last row of a table in DolphinDB?

From Dev

How to display JSON object in table format using javascript or jquery?

From Dev

Publish and subscribe both ways using MQTT Python

From Dev

Mqtt publish each element of an array using nodejs

From Dev

Publish and subscribe to MQTT topics using MQTT.js and Mosquitto

From Dev

How to publish a message to a specific client in Mosquitto MQTT

From Dev

How to publish to an IoT MQTT topic from a Lambda

From Dev

How to publish message from AWS Lambda to Raspberry Pi using MQTT in Python?

From Dev

how to format a table using nokogiri as in specified format

From Dev

How to join json list with a table in SQL Server using OPENJSON?

From Dev

How to convert string format of time type field in DolphinDB c ++ API

From Dev

How to capture MQTT data locally in SSH remote server using Wireshark?

From Dev

Convert json to long format table using jq

From Dev

posting data to server in json format using volley

Related Related

  1. 1

    How to publish a table in dolphinDB?

  2. 2

    How to publish data to using MQTT

  3. 3

    How to publish json data on mqtt broker in python?

  4. 4

    How to ungroup a table in DolphinDB?

  5. 5

    How to check if a shared table exists using DolphinDB Python API?

  6. 6

    Is it possible to publish a file into MQTT server?

  7. 7

    How to format a JSON string as a table using jq?

  8. 8

    How to format a JSON string as a table using jq?

  9. 9

    How to show json data in a table format retrieved from node.js server using Angular Js

  10. 10

    how to publish MQTT messages concurrently using java client?

  11. 11

    How to generate a random values periodically and publish it using MQTT protocol?

  12. 12

    How to implement MQTT server using Spring Integration?

  13. 13

    How to format/customize data in table columns using datatables server processing?

  14. 14

    How to remove duplication row from dolphindb table?

  15. 15

    How to convert a list of dictionary to a table in DolphinDB

  16. 16

    How to remove the last row of a table in DolphinDB?

  17. 17

    How to display JSON object in table format using javascript or jquery?

  18. 18

    Publish and subscribe both ways using MQTT Python

  19. 19

    Mqtt publish each element of an array using nodejs

  20. 20

    Publish and subscribe to MQTT topics using MQTT.js and Mosquitto

  21. 21

    How to publish a message to a specific client in Mosquitto MQTT

  22. 22

    How to publish to an IoT MQTT topic from a Lambda

  23. 23

    How to publish message from AWS Lambda to Raspberry Pi using MQTT in Python?

  24. 24

    how to format a table using nokogiri as in specified format

  25. 25

    How to join json list with a table in SQL Server using OPENJSON?

  26. 26

    How to convert string format of time type field in DolphinDB c ++ API

  27. 27

    How to capture MQTT data locally in SSH remote server using Wireshark?

  28. 28

    Convert json to long format table using jq

  29. 29

    posting data to server in json format using volley

HotTag

Archive