This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = {} | |
await wavecake.ble.connect('', '0000180f-0000-1000-8000-00805f9b34fb') | |
while(true) { | |
result = await wavecake.ble.readCharacteristic('', '0000180f-0000-1000-8000-00805f9b34fb', '00002a19-0000-1000-8000-00805f9b34fb') | |
wavecake.ui.message("Battery Level: " + result.data[0] + "%") | |
wavecake.ui.data(result.data[0]) | |
await timeout(1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//prototypes | |
function wavecake.ui.data(data); // adds data to the widget line chart | |
function wavecake.ui.message(message); // displays or updates message | |
function wavecake.ui.result(status); // turns widget green ("PASS"), red ("FAIL"), or white ("PENDING") | |
//examples | |
wavecake.ui.message("Battery Level: " + result.data[0] + "%") | |
wavecake.ui.data(result.data[0]) | |
wavecake.ui.result("PASS") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result: {status: string, data: Uint8Array } = {} | |
var commandStartHil = 1 | |
await wavecake.ble.setReconnect('','0000180f-0000-1000-8000-00805f9b34fb'); | |
while(true) { | |
result = await wavecake.mqtt.expect('wavecake') | |
if (result.data[0] === commandStartHil) { | |
await wavecake.ble.connect('', '0000180f-0000-1000-8000-00805f9b34fb'); | |
await wavecake.ble.notifyEnable('', '0000180f-0000-1000-8000-00805f9b34fb', '00002a19-0000-1000-8000-00805f9b34fb'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = await wavecake.ble.connect('', '6E400001-B5A3-F393-E0A9-E50E24DCCA9E'); | |
await wavecake.ble.notifyEnable('','6E400001-B5A3-F393-E0A9-E50E24DCCA9E','6E400003-B5A3-F393-E0A9-E50E24DCCA9E'); | |
await wavecake.ble.writeCharacteristic('','6E400001-B5A3-F393-E0A9-E50E24DCCA9E','6E400002-B5A3-F393-E0A9-E50E24DCCA9E','90,101,110,100'); | |
await wavecake.ble.notifyExpect('','6E400001-B5A3-F393-E0A9-E50E24DCCA9E','6E400003-B5A3-F393-E0A9-E50E24DCCA9E'); | |
await wavecake.ble.disconnect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//prototypes | |
async function connect(baudRate); | |
async function readStringUntil(until='\r'); | |
async function writeString(text, ending='\r') | |
async function disconnect(); | |
//examples | |
await wavecake.serial.connect(9600) | |
await wavecake.serial.writeString("Hello World") | |
result = await wavecake.serial.readStringUntil() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//prototypes | |
//functions without a host argument use unauthenticated mqtt://test.mosquitto.org:1883 by default | |
async function expect(topic); | |
async function publish(topic, publishValue); | |
async function expectCustom(host, username, password, topic, publishValue); | |
async function publishCustom(host, username, password, topic, publishValue); | |
//examples | |
var result: {status: string, data: Uint8Array } = {} | |
await wavecake.mqtt.expect('wavecake'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//prototypes | |
async function connect(name, service_uuids); | |
async function notifyExpect(name, service_uuids, characteristic_uuid, expect); | |
async function notifyEnable(name, service_uuids, characteristic_uuid); | |
async function readCharacteristic(name, service_uuids, characteristic_uuid, expect); | |
async function writeCharacteristic(name, service_uuids, characteristic_uuid, write_value); | |
async function writeCharacteristicAndExpect(name, service_uuids, characteristic_uuid, write_value); | |
async function disconnect(); | |
//example |