os module needs to be required first
This commit is contained in:
parent
35feed7775
commit
57efee6d7f
|
@ -3,7 +3,11 @@
|
||||||
/** @module ble */
|
/** @module ble */
|
||||||
/** Bluetooth Low Energy module */
|
/** 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 DEVICE_NAME = process.env.DEVICE_ID || 'intval3'
|
||||||
const SERVICE_ID = process.env.SERVICE_ID || 'intval3_ble'
|
const SERVICE_ID = process.env.SERVICE_ID || 'intval3_ble'
|
||||||
|
@ -13,13 +17,8 @@ const NETWORK = os.networkInterfaces()
|
||||||
const MAC = getMac() || spoofMac()
|
const MAC = getMac() || spoofMac()
|
||||||
|
|
||||||
process.env.BLENO_DEVICE_NAME += '_' + MAC
|
process.env.BLENO_DEVICE_NAME += '_' + MAC
|
||||||
|
|
||||||
const os = require('os')
|
|
||||||
const bleno = require('bleno')
|
const bleno = require('bleno')
|
||||||
const util = require('util')
|
|
||||||
|
|
||||||
const log = require('../log')('ble')
|
|
||||||
const wifi = require('../wifi')
|
|
||||||
|
|
||||||
let currentWifi = 'disconnected'
|
let currentWifi = 'disconnected'
|
||||||
let getState
|
let getState
|
||||||
|
@ -135,7 +134,7 @@ class BLE {
|
||||||
bleno.on('stateChange', state => {
|
bleno.on('stateChange', state => {
|
||||||
log.info('stateChange', { state : state })
|
log.info('stateChange', { state : state })
|
||||||
if (state === 'poweredOn') {
|
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])
|
bleno.startAdvertising(DEVICE_NAME, [CHAR_ID])
|
||||||
} else {
|
} else {
|
||||||
bleno.stopAdvertising()
|
bleno.stopAdvertising()
|
||||||
|
|
Loading…
Reference in New Issue