Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
setTimeout(() => {
/* Test read current RSSI value
BleManager.retrieveServices(peripheral.id).then((peripheralData) => {
console.log('Retrieved peripheral services', peripheralData);
BleManager.readRSSI(peripheral.id).then((rssi) => {
console.log('Retrieved actual RSSI value', rssi);
});
});*/
// Test using bleno's pizza example
// https://github.com/sandeepmistry/bleno/tree/master/examples/pizza
BleManager.retrieveServices(peripheral.id).then((peripheralInfo) => {
console.log(peripheralInfo);
var service = '13333333-3333-3333-3333-333333333337';
var bakeCharacteristic = '13333333-3333-3333-3333-333333330003';
var crustCharacteristic = '13333333-3333-3333-3333-333333330001';
setTimeout(() => {
BleManager.startNotification(peripheral.id, service, bakeCharacteristic).then(() => {
console.log('Started notification on ' + peripheral.id);
setTimeout(() => {
BleManager.write(peripheral.id, service, crustCharacteristic, [0]).then(() => {
console.log('Writed NORMAL crust');
BleManager.write(peripheral.id, service, bakeCharacteristic, [1,95]).then(() => {
console.log('Writed 351 temperature, the pizza should be BAKED');
/*
var PizzaBakeResult = {
HALF_BAKED: 0,
console.log('Cancel Pressed')
}
},
{
text: 'OK',
onPress: (fullname) => {
this.enterRoom(fullname);
}
}
],
{
placeholder: 'John Wick'
}
);
BleManager.retrieveServices(peripheral_id)
.then((peripheralInfo) => {
console.log('Peripheral info:', peripheralInfo);
}
);
})
.catch((error) => {
.then( () => {
console.log('Connected');
return BleManager.retrieveServices(id)
}).then( (peripheralInfo)=>{
console.log('Connected peripheralInfo: ', peripheralInfo);
setTimeout(() => {
BleManager.retrieveServices(id).then((peripheralInfo) => {
console.log(peripheralInfo);
var service = '4fafc201-1fb5-459e-8fcc-c5c9c331914b';
var tareCharacteristic = 'beb5483e-36e1-4688-b7f5-ea07361b26a8';
var loadCellCharacteristic = '4a78b8dd-a43d-46cf-9270-f6b750a717c8'; //calibrate as well
setTimeout(() => {
BleManager.startNotification(id, service, loadCellCharacteristic).then(() => {
console.log('Started sensing/notification on ' + id);
}).catch((error) => {
console.log('Notification error', error);
});
}, 200);
});
}, 900);
}).catch((error) => {
.then(() => {
console.log('Connected success.');
return BleManager.retrieveServices(id);
})
.then((peripheralInfo)=>{
BleManager.connect(p.id).then(() => {
BleManager.retrieveServices(p.id).then((peripheralInfo) => {
console.log(peripheralInfo);
p.advertising.serviceUUIDs = [peripheralInfo.services[2].uuid];
changePeripherals({"action": "add", "peripheral": p});
});
});
}