Skip to content

Instantly share code, notes, and snippets.

@meganetaaan
Created January 10, 2023 17:11
Show Gist options
  • Save meganetaaan/40a7c31d9b372f2c7d962a078121cab8 to your computer and use it in GitHub Desktop.
Save meganetaaan/40a7c31d9b372f2c7d962a078121cab8 to your computer and use it in GitHub Desktop.
BLEのアドバタイジングパケットのユーザ定義領域の値を動的に変えるテスト
import BLEServer from "bleserver";
import Timer from "timer";
let count = 0;
class Advertiser extends BLEServer {
onReady() {
}
onConnected(connection) {
this.stopAdvertising();
}
onDisconnected(connection) {
}
}
let advertiser = new Advertiser();
Timer.repeat(() => {
count++;
advertiser.startAdvertising({
advertisingData: {
flags: 6,
completeName: "M5Stack",
manufacturerSpecific: {
identifier: 0x39,
data: [ count ],
},
},
});
}, 1000);
{
"include": [
"$(MODDABLE)/examples/manifest_base.json",
"$(MODDABLE)/modules/network/ble/manifest_server.json"
],
"modules": {
"*": [
"./main"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment