Compile ble module with typescript. Add globals file to prevent errors.
This commit is contained in:
parent
b4091bf06b
commit
7d779bc5c9
|
@ -164,8 +164,8 @@ class BLE {
|
||||||
this.listeners = {};
|
this.listeners = {};
|
||||||
log.info('Starting bluetooth service');
|
log.info('Starting bluetooth service');
|
||||||
getState = bleGetState;
|
getState = bleGetState;
|
||||||
bleno_1.default.on('stateChange', state => {
|
bleno_1.default.on('stateChange', (state) => {
|
||||||
log.info('stateChange', { state: state });
|
log.info('stateChange', { state });
|
||||||
if (state === 'poweredOn') {
|
if (state === 'poweredOn') {
|
||||||
log.info('Starting advertising', { DEVICE_NAME, DEVICE_ID: process.env.BLENO_DEVICE_NAME });
|
log.info('Starting advertising', { DEVICE_NAME, DEVICE_ID: process.env.BLENO_DEVICE_NAME });
|
||||||
bleno_1.default.startAdvertising(DEVICE_NAME, [CHAR_ID]);
|
bleno_1.default.startAdvertising(DEVICE_NAME, [CHAR_ID]);
|
||||||
|
@ -174,7 +174,7 @@ class BLE {
|
||||||
bleno_1.default.stopAdvertising();
|
bleno_1.default.stopAdvertising();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bleno_1.default.on('advertisingStart', err => {
|
bleno_1.default.on('advertisingStart', (err) => {
|
||||||
log.info('advertisingStart', { res: (err ? 'error ' + err : 'success') });
|
log.info('advertisingStart', { res: (err ? 'error ' + err : 'success') });
|
||||||
createChars(this._onWrite.bind(this), this._onRead.bind(this));
|
createChars(this._onWrite.bind(this), this._onRead.bind(this));
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
@ -186,11 +186,11 @@ class BLE {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
bleno_1.default.on('accept', clientAddress => {
|
bleno_1.default.on('accept', (clientAddress) => {
|
||||||
log.info('accept', { clientAddress: clientAddress });
|
log.info('accept', { clientAddress });
|
||||||
});
|
});
|
||||||
bleno_1.default.on('disconnect', clientAddress => {
|
bleno_1.default.on('disconnect', (clientAddress) => {
|
||||||
log.info('disconnect', { clientAddress: clientAddress });
|
log.info('disconnect', { clientAddress });
|
||||||
});
|
});
|
||||||
this._refreshWifi();
|
this._refreshWifi();
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -198,8 +198,8 @@ class BLE {
|
||||||
|
|
||||||
getState = bleGetState
|
getState = bleGetState
|
||||||
|
|
||||||
bleno.on('stateChange', state => {
|
bleno.on('stateChange', (state : any ) => {
|
||||||
log.info('stateChange', { state : state })
|
log.info('stateChange', { state })
|
||||||
if (state === 'poweredOn') {
|
if (state === 'poweredOn') {
|
||||||
log.info('Starting advertising', { DEVICE_NAME, DEVICE_ID : process.env.BLENO_DEVICE_NAME })
|
log.info('Starting advertising', { DEVICE_NAME, DEVICE_ID : process.env.BLENO_DEVICE_NAME })
|
||||||
bleno.startAdvertising(DEVICE_NAME, [CHAR_ID])
|
bleno.startAdvertising(DEVICE_NAME, [CHAR_ID])
|
||||||
|
@ -208,7 +208,7 @@ class BLE {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
bleno.on('advertisingStart', err => {
|
bleno.on('advertisingStart', (err : Error) => {
|
||||||
log.info('advertisingStart', { res : (err ? 'error ' + err : 'success') })
|
log.info('advertisingStart', { res : (err ? 'error ' + err : 'success') })
|
||||||
createChars(this._onWrite.bind(this), this._onRead.bind(this))
|
createChars(this._onWrite.bind(this), this._onRead.bind(this))
|
||||||
if (!err) {
|
if (!err) {
|
||||||
|
@ -221,12 +221,12 @@ class BLE {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
bleno.on('accept', clientAddress => {
|
bleno.on('accept', (clientAddress : any) => {
|
||||||
log.info('accept', { clientAddress : clientAddress })
|
log.info('accept', { clientAddress })
|
||||||
})
|
})
|
||||||
|
|
||||||
bleno.on('disconnect', clientAddress => {
|
bleno.on('disconnect', (clientAddress : any) => {
|
||||||
log.info('disconnect', { clientAddress : clientAddress })
|
log.info('disconnect', { clientAddress })
|
||||||
})
|
})
|
||||||
|
|
||||||
this._refreshWifi()
|
this._refreshWifi()
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
declare module 'bleno';
|
Loading…
Reference in New Issue