Skip to content

Instantly share code, notes, and snippets.

@half2me
Last active February 15, 2024 12:13
Show Gist options
  • Save half2me/dbc0eaee491c52b968090fbbb832bab0 to your computer and use it in GitHub Desktop.
Save half2me/dbc0eaee491c52b968090fbbb832bab0 to your computer and use it in GitHub Desktop.

Revisions

  1. half2me revised this gist Feb 15, 2024. 1 changed file with 31 additions and 3 deletions.
    34 changes: 31 additions & 3 deletions antplus.lua
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,44 @@
    -- requires https://github.com/Snaipe/wssdl/releases/download/v0.2.0/wssdl.lua
    local wssdl = require 'wssdl'

    ant_pkt = wssdl.packet {
    ant_msg = wssdl.packet {
    sync:u8():hex(),
    length:u8(),
    class:u8():hex(),
    payload:payload({ class, 'antplus.class' }, length * 8),
    checksum:u8():hex()
    }

    proto = ant_pkt:proto('antplus', 'ANT+ Protocol')
    ant_broadcast_event = wssdl.packet {
    channel:u8(),
    payload:bytes(8),
    extendedFlag:u8():hex(),
    deviceNumber:u16():le(),
    deviceType:u8():hex(),
    transmissionType:u8():hex(),
    --rssiMeasurementType:u8():hex(),
    --rssi:u8(),
    --rssiThreshold:u8(),
    --rxTimestamp:u16():le(),
    }

    ant_power_msg = wssdl.packet {
    page:u8(),
    eventCount:u8(),
    unknown:u8(),
    instantaneousCadence:u8(),
    accumulatedPower:u16(),
    instantaneousPower:u16(),
    }

    wssdl.dissect {
    usb.bulk:add { [0xFFFF] = proto }
    usb.bulk:add {
    [0xFFFF] = ant_msg:proto('antplus', 'ANT+ Protocol')
    },
    antplus.class:add {
    [0x4E] = ant_broadcast_event:proto('antplus_broadcast_event', 'ANT+ Broadcast Event')
    },
    --antplus_broadcast_event.deviceType:add {
    -- [0x0B] = ant_power_msg:proto('antplus_power_meter', 'ANT+ Power Meter')
    --},
    }
  2. half2me renamed this gist Feb 15, 2024. 1 changed file with 3 additions and 5 deletions.
    8 changes: 3 additions & 5 deletions gistfile1.txt → antplus.lua
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,16 @@
    -- requires https://github.com/Snaipe/wssdl/releases/download/v0.2.0/wssdl.lua
    local wssdl = require 'wssdl'

    ant_pkt = wssdl.packet {
    sync:u8():hex(),
    length:u8(),
    class:u8():hex(),
    payload:payload(class),
    payload:payload({ class, 'antplus.class' }, length * 8),
    checksum:u8():hex()
    }

    proto = ant_pkt:proto('antplus', 'ANT+ Protocol')

    wssdl.dissect {
    usb.bulk:add {
    [0xFF] = proto,
    [0xFFFF] = proto
    }
    usb.bulk:add { [0xFFFF] = proto }
    }
  3. half2me created this gist Feb 14, 2024.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    local wssdl = require 'wssdl'

    ant_pkt = wssdl.packet {
    sync:u8():hex(),
    length:u8(),
    class:u8():hex(),
    payload:payload(class),
    checksum:u8():hex()
    }

    proto = ant_pkt:proto('antplus', 'ANT+ Protocol')

    wssdl.dissect {
    usb.bulk:add {
    [0xFF] = proto,
    [0xFFFF] = proto
    }
    }