Skip to content

Instantly share code, notes, and snippets.

@tresf
Created February 28, 2020 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tresf/7abfdfc3facf0a340004e6bfb1e6ca3e to your computer and use it in GitHub Desktop.
Save tresf/7abfdfc3facf0a340004e6bfb1e6ca3e to your computer and use it in GitHub Desktop.
// Calculate bits (most significant, least significant)
// **WARNING** Magic counting to follow:
// 1. MSB incriments when LSB hits 0x46 hex
// 2. Counting is done using decimal, BUT...
// 3. Decimal is strangly passed in hex format
var msb = parseInt(30 + Math.floor(((dBm + 2) + 30)/46), 16);
var lsb = parseInt(30 + ((dBm + 2) % 46), 16);
console.log("Setting power level to", dBm + "dBm = ", "MSB:", msb.toString(16), "LSB:", lsb.toString(16));
return qz.hid.sendData({
vendorId: vid,
productId: pid,
usagePage: usage,
endpoint: 0x08,
data: [0x02, 0x41, 0x4E, 0x31, 0x2C, msb, lsb],
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment