Use a better device id

This commit is contained in:
mmcwilliams 2017-12-13 18:31:59 -05:00
parent 567b1bb55d
commit 6cabd0e926
1 changed files with 5 additions and 5 deletions

View File

@ -10,13 +10,14 @@ const util = require('util')
const log = require('../log')('ble') const log = require('../log')('ble')
const wifi = require('../wifi') const wifi = require('../wifi')
const BLENO_DEVICE_NAME = process.env.BLENO_DEVICE_NAME || 'intval3' const DEVICE_NAME = process.env.DEVICE_ID || 'intval3'
let DEVICE_ID = process.env.DEVICE_ID || 'intval3'
const SERVICE_ID = process.env.SERVICE_ID || 'intval3_ble' const SERVICE_ID = process.env.SERVICE_ID || 'intval3_ble'
const CHAR_ID = process.env.CHAR_ID || 'intval3char' const CHAR_ID = process.env.CHAR_ID || 'intval3char'
const WIFI_ID = process.env.WIFI_ID || 'wifichar' const WIFI_ID = process.env.WIFI_ID || 'wifichar'
const NETWORK = os.networkInterfaces() const NETWORK = os.networkInterfaces()
const MAC = getMac() || spoofMac() const MAC = getMac() || spoofMac()
//
process.env.BLENO_DEVICE_NAME += '_' + MAC
let currentWifi = 'disconnected' let currentWifi = 'disconnected'
let getState let getState
@ -130,11 +131,10 @@ class BLE {
getState = bleGetState getState = bleGetState
bleno.on('stateChange', state => { bleno.on('stateChange', state => {
const BLE_ID = `${DEVICE_ID}_${MAC}`
log.info('stateChange', { state : state }) log.info('stateChange', { state : state })
if (state === 'poweredOn') { if (state === 'poweredOn') {
log.info('Starting advertising', { BLE_ID : BLE_ID }) log.info('Starting advertising', { DEVICE_NAME: DEVICE_NAME })
bleno.startAdvertising(BLE_ID, [CHAR_ID]) bleno.startAdvertising(DEVICE_NAME, [CHAR_ID])
} else { } else {
bleno.stopAdvertising() bleno.stopAdvertising()
} }