os module needs to be required first

This commit is contained in:
mmcwilliams 2017-12-13 18:35:59 -05:00
parent 35feed7775
commit 57efee6d7f
1 changed files with 5 additions and 6 deletions

View File

@ -3,7 +3,11 @@
/** @module ble */
/** Bluetooth Low Energy module */
const util = require('util')
const os = require('os')
const log = require('../log')('ble')
const wifi = require('../wifi')
const DEVICE_NAME = process.env.DEVICE_ID || 'intval3'
const SERVICE_ID = process.env.SERVICE_ID || 'intval3_ble'
@ -13,13 +17,8 @@ const NETWORK = os.networkInterfaces()
const MAC = getMac() || spoofMac()
process.env.BLENO_DEVICE_NAME += '_' + MAC
const os = require('os')
const bleno = require('bleno')
const util = require('util')
const log = require('../log')('ble')
const wifi = require('../wifi')
let currentWifi = 'disconnected'
let getState
@ -135,7 +134,7 @@ class BLE {
bleno.on('stateChange', state => {
log.info('stateChange', { state : state })
if (state === 'poweredOn') {
log.info('Starting advertising', { DEVICE_NAME: DEVICE_NAME })
log.info('Starting advertising', { DEVICE_NAME: DEVICE_NAME, DEVICE_ID : process.env.BLENO_DEVICE_NAME })
bleno.startAdvertising(DEVICE_NAME, [CHAR_ID])
} else {
bleno.stopAdvertising()