Skip to content

Instantly share code, notes, and snippets.

@jacksonkeating
Last active December 31, 2023 03:34
Show Gist options
  • Save jacksonkeating/95594f2d4d93a0206a650ed4ec736e09 to your computer and use it in GitHub Desktop.
Save jacksonkeating/95594f2d4d93a0206a650ed4ec736e09 to your computer and use it in GitHub Desktop.
//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
var result: {status: string, data: Uint8Array } = {}
await wavecake.ble.connect('', '0000180f-0000-1000-8000-00805f9b34fb','0059');
await wavecake.ble.notifyEnable('', '0000180f-0000-1000-8000-00805f9b34fb', '00002a19-0000-1000-8000-00805f9b34fb');
await wavecake.ble.writeCharacteristicAndExpect('','12345678-1234-5678-1234-56789abcdef0','12345678-1234-5678-1234-56789abcdef3','90,101,110,100,111,114,32,100,97,116,97,51,86,101,110,100,111,114,32,100,97,116,97,50,86,101,110,100,111,114,32,100,97,116,97,51,86,101,110,100,111,114,32,100,97,116,97,52,86,101,110,100,111,114,32,100,97,116,97,53,86,101,110,100,111,114,32,100,97,116,97,51,46,32');
await wavecake.ble.readCharacteristic('','12345678-1234-5678-1234-56789abcdef0','12345678-1234-5678-1234-56789abcdef3');
await wavecake.ble.writeCharacteristic('','12345678-1234-5678-1234-56789abcdef0','12345678-1234-5678-1234-56789abcdef3','100,101,110,100,111,114,32,100,97,116,97,51,86,101,110,100,111,114,32,100,97,116,97,50,86,101,110,100,111,114,32,100,97,116,97,51,86,101,110,100,111,114,32,100,97,116,97,52,86,101,110,100,111,114,32,100,97,116,97,53,86,101,110,100,111,114,32,100,97,116,97,51,46,32');
await wavecake.ble.notifyExpect('', '0000180f-0000-1000-8000-00805f9b34fb', '00002a19-0000-1000-8000-00805f9b34fb');
await wavecake.ble.disconnect();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment