particle-iot / particle-usb

A library for accessing Particle USB devices
Apache License 2.0
5 stars 1 forks source link

Introduce low level way to interact directly with Device OS control requests over USB #56

Closed joegoggins closed 2 years ago

joegoggins commented 2 years ago

Overview

This PR introduces the ability to interact with Device OS via USB control requests even if the there isn't a corresponding high level method in particle-usb. For example, Device OS exposes a wifi.JoinNewNetworkRequest protobuf message, but it cannot be used because there is no corresponding high level method like joinNewWifiNetwork() implemented yet on particle-usb. In this situation, with this code, you can interact directly via the new sendProtobufRequest if need to.

Change summary

See sc-95109 for more context/details.

Script used to validate photon, p1, boron enterListeningMode still works

const particleUSB = require('./src/particle-usb');
async function main() {
    const devices = await particleUSB.getDevices();
    const device = devices[0];
    await device.open();

    const highLevelReply = await device.enterListeningMode();
    console.log('highLevelReply', highLevelReply);

    // const lowLevelReply = await device.sendProtobufRequest('StartListeningModeRequest');
    // console.log('lowLevelReply', lowLevelReply);

    await device.close();
}

main();

out of scope

This PR is deliberately small. Hoping to align, address feedback, merge on this first, then pursue this work in other PRs: