Skip to content

Instantly share code, notes, and snippets.

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)
//prototypes
function wavecake.ui.data(data); // adds data to the widget line chart
function wavecake.ui.message(message); // displays or updates message
//examples
wavecake.ui.message("Battery Level: " + result.data[0] + "%")
wavecake.ui.data(result.data[0])
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');
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();
//prototypes
async function connect(baudRate);
async function readExpect();
async function write(writeValue);
async function disconnect();
//examples
var result: {status: string, data: Uint8Array } = {}
await wavecake.serial.connect(115200);
await wavecake.serial.readExpect();
//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');
//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