Cloud Adapter
Supports cloud connections to upload and download data.
import * as ds from "@devicescript/core"
const client = new ds.MQTTClient()
Registers
uploadJson(topic:string, json:string)
Upload a JSON-encoded message to the cloud.
import * as ds from "@devicescript/core"
const mqtt = new ds.MQTTClient()
await mqtt.uploadJson('jacdac','') // topic:string, json:string
uploadBinary(topic:string, bytes:Uint8Array)
Upload a binary message to the cloud.
import * as ds from "@devicescript/core"
const mqtt = new ds.MQTTClient()
await mqtt.uploadBinary('jacdac',Uint8Array) // topic:string, bytes:Uint8Array
Events
onJson([topic:string, json:string])
Upload a JSON-encoded message to the cloud.
mqtt.onJson.subscribe(async (json:[topic:string,json:string]) => {
...
})
onBinary([topic:string, payload:Uint8Array])
Emitted when cloud send us a binary message.
mqtt.onBinary.subscribe(async (json:[topic:string,payload:Uint8Array]) => {
...
})