Skip to content

Improve code clarity #1003

@murkle

Description

@murkle

Library works great, thanks for the pointer :)

The code would be clearer in constants.js if you did this instead of having placeholder 0x00 bytes that are later changed

eg

function getStartMeasurementCommand(channelMask) {
    return [
        0x18,
        0xff,
        0x01, (channelMask >> 0) & 0xff, (channelMask >> 8) & 0xff, (channelMask >> 16) & 0xff, (channelMask >> 24) & 0xff,
        0x00,
        0x00,
        0x00,
        0x00,
        0x00,
        0x00,
        0x00,
        0x00,
    ];
}

const STOP_MEASUREMENTS = [0x19, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff];

function getMeasurementPeriodCommand(measurementPeriodInMicroseconds) {
    // 32 + (161<<8) + (7<<16) + (0<<24) = 500,000 microseconds
    return [
        0x1b,
        0xff,
        0x00, (measurementPeriodInMicroseconds >> 0) & 0xff, // eg 32
        (measurementPeriodInMicroseconds >> 8) & 0xff, // eg 161
        (measurementPeriodInMicroseconds >> 16) & 0xff, // eg 7
        (measurementPeriodInMicroseconds >> 24) & 0xff, //eg 0
        0x00,
        0x00,
        0x00,
        0x00,
    ];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions