arduino-bitcoin / simple_hardware_wallet

A minimalistic bitcoin hardware wallet for Arduino
MIT License
41 stars 11 forks source link

Spec out the protocol for WebUSB communication #23

Open justinmoon opened 5 years ago

justinmoon commented 5 years ago

The port object I'm currently getting from arduino-webusb has a .send() method that will send a string over the WebUSB connection to the device. But this .send() doesn't provide the actual response from the Arduino.

In https://github.com/arduino-bitcoin/simple_hardware_wallet/pull/21 I prototyped a protocol where the Arduino would send a comma-delimited command,payload message to the UI, which the UI would listen for and handle.

This works but it doesn't seem optimal to me. It will become complicated to keep track of loading states. And it's ugly.

Hopefully we can find a better way ...

justinmoon commented 5 years ago

Stepan was saying how it would probably be better to send bytes instead of strings.

Something like Serial.write(arr, sizeof(arr)); where arr is our message: an array of bytes