Use a better device id
This commit is contained in:
parent
567b1bb55d
commit
6cabd0e926
|
@ -10,13 +10,14 @@ const util = require('util')
|
|||
const log = require('../log')('ble')
|
||||
const wifi = require('../wifi')
|
||||
|
||||
const BLENO_DEVICE_NAME = process.env.BLENO_DEVICE_NAME || 'intval3'
|
||||
let DEVICE_ID = process.env.DEVICE_ID || 'intval3'
|
||||
const DEVICE_NAME = process.env.DEVICE_ID || 'intval3'
|
||||
const SERVICE_ID = process.env.SERVICE_ID || 'intval3_ble'
|
||||
const CHAR_ID = process.env.CHAR_ID || 'intval3char'
|
||||
const WIFI_ID = process.env.WIFI_ID || 'wifichar'
|
||||
const NETWORK = os.networkInterfaces()
|
||||
const MAC = getMac() || spoofMac()
|
||||
//
|
||||
process.env.BLENO_DEVICE_NAME += '_' + MAC
|
||||
|
||||
let currentWifi = 'disconnected'
|
||||
let getState
|
||||
|
@ -130,11 +131,10 @@ class BLE {
|
|||
getState = bleGetState
|
||||
|
||||
bleno.on('stateChange', state => {
|
||||
const BLE_ID = `${DEVICE_ID}_${MAC}`
|
||||
log.info('stateChange', { state : state })
|
||||
if (state === 'poweredOn') {
|
||||
log.info('Starting advertising', { BLE_ID : BLE_ID })
|
||||
bleno.startAdvertising(BLE_ID, [CHAR_ID])
|
||||
log.info('Starting advertising', { DEVICE_NAME: DEVICE_NAME })
|
||||
bleno.startAdvertising(DEVICE_NAME, [CHAR_ID])
|
||||
} else {
|
||||
bleno.stopAdvertising()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue