import { IConfig, IGroup } from 'app/nodes/configs.interfaces'; import { CONFIG } from 'app/nodes/types'; import { createBaseParam, createBaseData } from 'app/nodes/utils'; const ecgParam = createBaseParam({ title: 'ECG Config', service: 'bf10', characteristic: 'bf13' }); const ecgData = createBaseData({ title: 'ECG Data', service: 'bf10', littleEndian: true, bytesPerSample: 3, bytesPerPackage: 12 }); const samplingFrequency = ecgParam({ name: 'Sampling frequency', offset: 0, bits: 8, values: [ { key: '125 Hz', value: 0 }, { key: '250 Hz', value: 1 }, { key: '500 Hz', value: 2 }, { key: '1 kHz', value: 3 }, { key: '2 kHz', value: 4 }, { key: '4 kHz', value: 5 }, { key: '8 kHz', value: 6 } ] }); const ecgChannel1 = ecgData({ name: 'ECG Channel 1', characteristic: 'bf11', read: readECG }); const ecgChannel2 = ecgData({ name: 'ECG Channel 2', characteristic: 'bf12', read: readECG }); const samplingFrequencyGroup: IGroup = { title: 'Sampling Frequency', sections: [ { title: ecgChannel1.title, toggle: ecgChannel1 }, { title: ecgChannel2.title, toggle: ecgChannel2 }, { title: 'Sampling Frequency', items: [samplingFrequency] } ] }; function readECG(buffer: Buffer) { const bytesPerSample = 3; const data: number[] = []; for (let i = 0; i < 4; i++) { data.push(buffer.readIntBE(i * bytesPerSample, bytesPerSample)); } return data; } export const groups: IGroup[] = [samplingFrequencyGroup];