This stops advertisement of BLE.
// Javascript Example
await obniz.ble.initWait();
await obniz.ble.extendedAdvertisement.startWait();
await obniz.ble.extendedAdvertisement.endWait();
This sets advertise data from json.
// Javascript Example
await obniz.ble.initWait();
obniz.ble.extendedAdvertisement.setAdvData({
flags: ["general_discoverable_mode","br_edr_not_supported"],
manufacturerData:{
companyCode : 0x004C,
serviceUuids: ["fff0"],
data : [0x02,0x15, 0xC2, 0x8f, 0x0a, 0xd5, 0xa7, 0xfd, 0x48, 0xbe, 0x9f, 0xd0, 0xea, 0xe9, 0xff, 0xd3, 0xa8, 0xbb,0x10,0x00,0x00,0x10,0xFF],
}
});
await obniz.ble.extendedAdvertisement.startWait();
This sets advertise data from data array.
// Javascript Example
await obniz.ble.initWait();
obniz.ble.extendedAdvertisement.setAdvDataRaw([0x02, 0x01, 0x1A, 0x07, 0x09, 0x53, 0x61, 0x6D, 0x70, 0x6C, 0x65 ]);
//0x02, 0x01, 0x1A => BLE type for
//0x07, 0x09, 0x53, 0x61, 0x6D, 0x70, 0x6C, 0x65 => Set name
await obniz.ble.extendedAdvertisement.startWait();
AdvertiseMode can be changed
broadcast MAX advData 1650Byte connectable MAX advData 242Byte default scannable MAX scanRspData 1650Byte
// Javascript Example
await obniz.ble.initWait();
obniz.ble.extendedAdvertisement.setMode(broadcast);
obniz.ble.extendedAdvertisement.setAdvData({
localName: "test_obniz",
serviceData:[{
uuid:0x2534,
data:[0x55,0x55,0x55,0x55,0x55,0x65,0x65,0x65,5,0x55,0x55,0x65,0x55,0x55,0x65,0x65,0x55,0x55,0x55,0x55,]
},{
uuid:0x3544,
data:[0x55,0x55,0x55,0x55,0x55,0x65,0x65,0x65,0x65,0x55,0x55,0x55,0x65,0x55,0x55,0x65,0x65,0x55,0x55,0x55,0x55,]
}]
})
await obniz.ble.extendedAdvertisement.startWait();
BleExtendedAdvertisementMode
This sets scan response data from json data.
// Javascript Example
await obniz.ble.initWait();
obniz.ble.extendedAdvertisement.setScanRespData({
localName : "obniz BLE",
});
await obniz.ble.advertisement.startWait();
This sets scan response data from data array.
// Javascript Example
await obniz.ble.initWait();
obniz.ble.extendedAdvertisement.setScanRespDataRaw([0x07, 0x09, 0x53, 0x61, 0x6D, 0x70, 0x6C, 0x65 ]);
//0x07, 0x09, 0x53, 0x61, 0x6D, 0x70, 0x6C, 0x65 => Set name
await obniz.ble.advertisement.startWait();
This starts advertisement of BLE.
Before calling this function, you should call setAdvData or setAdvDataRaw to set data. advertisement interval is 1.28sec fixed.
primaryPhy: 'PHY_1m' or 'PHY_Coded' secondaryPhy: 'PHY_1m' or 'PHY_2m' or 'PHY_Coded'
// Javascript Example
await obniz.ble.initWait();
var service = new obniz.ble.service({
uuid : "fff0"
});
obniz.ble.peripheral.addService(service);
obniz.ble.extendedAdvertisement.setAdvData({
flags:service.advData.flags,
serviceUuids:service.advData.serviceUuids,
localName: "test_obniz",
serviceData:[{
uuid:0x3544,
data:[0x55,0x55,0x55,0x55,0x55,0x65,0x65,0x65,0x65,0x55,0x55,0x55,0x65,0x55,0x55,0x65,0x65,0x55,0x55,0x55,0x55,]
}]
})
await obniz.ble.extendedAdvertisement.startWait('PHY_1m','PHY_2m');
Generated using TypeDoc