makes low level integrations less dependent on raspberry pi hardware
This commit is contained in:
parent
4a6f8d9cc1
commit
4e844b0722
|
|
@ -13,14 +13,14 @@
|
|||
*/
|
||||
import bleno from '@abandonware/bleno'
|
||||
import FitnessMachineService from './ftms/FitnessMachineService.js'
|
||||
import DeviceInformationService from './ftms/DeviceInformationService.js'
|
||||
// import DeviceInformationService from './ftms/DeviceInformationService.js'
|
||||
import config from '../tools/ConfigManager.js'
|
||||
import log from 'loglevel'
|
||||
|
||||
function createFtmsPeripheral (controlCallback, options) {
|
||||
const peripheralName = options?.simulateIndoorBike ? config.ftmsBikePeripheralName : config.ftmsRowerPeripheralName
|
||||
const fitnessMachineService = new FitnessMachineService(options, controlPointCallback)
|
||||
const deviceInformationService = new DeviceInformationService()
|
||||
// const deviceInformationService = new DeviceInformationService()
|
||||
|
||||
bleno.on('stateChange', (state) => {
|
||||
triggerAdvertising(state)
|
||||
|
|
@ -29,7 +29,8 @@ function createFtmsPeripheral (controlCallback, options) {
|
|||
bleno.on('advertisingStart', (error) => {
|
||||
if (!error) {
|
||||
bleno.setServices(
|
||||
[fitnessMachineService, deviceInformationService],
|
||||
// [fitnessMachineService, deviceInformationService],
|
||||
[fitnessMachineService],
|
||||
(error) => {
|
||||
if (error) log.error(error)
|
||||
})
|
||||
|
|
@ -86,7 +87,8 @@ function createFtmsPeripheral (controlCallback, options) {
|
|||
if (activeState === 'poweredOn') {
|
||||
bleno.startAdvertising(
|
||||
peripheralName,
|
||||
[fitnessMachineService.uuid, deviceInformationService.uuid],
|
||||
// [fitnessMachineService.uuid, deviceInformationService.uuid],
|
||||
[fitnessMachineService.uuid],
|
||||
(error) => {
|
||||
if (error) log.error(error)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ export function createGpioTimerService () {
|
|||
} catch (err) {
|
||||
log.debug('need root permission to set priority of Gpio-Thread')
|
||||
}
|
||||
|
||||
if (Gpio.accessible) {
|
||||
// mode can be rising, falling, both
|
||||
const reedSensor = new Gpio(17, 'in', 'rising')
|
||||
// use hrtime for time measurement to get a higher time precision
|
||||
|
|
@ -39,6 +41,9 @@ export function createGpioTimerService () {
|
|||
const delta = hrDelta[0] + hrDelta[1] / 1e9
|
||||
process.send(delta)
|
||||
})
|
||||
} else {
|
||||
log.info('reading from Gpio is not (yet) supported on this platform')
|
||||
}
|
||||
}
|
||||
|
||||
createGpioTimerService()
|
||||
|
|
|
|||
Loading…
Reference in New Issue