Reorder ext IDs, add board ID to ResponseInfo, fix CRLF translation
This commit is contained in:
@@ -82,6 +82,9 @@ func run(buildDir string) error {
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "warning: Info request failed: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf("Board ID: %02X%02X%02X%02X%02X%02X%02X%02X\n",
|
||||
info.BoardID[0], info.BoardID[1], info.BoardID[2], info.BoardID[3],
|
||||
info.BoardID[4], info.BoardID[5], info.BoardID[6], info.BoardID[7])
|
||||
fmt.Printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||
info.MAC[0], info.MAC[1], info.MAC[2],
|
||||
info.MAC[3], info.MAC[4], info.MAC[5])
|
||||
|
||||
@@ -5,10 +5,21 @@
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
struct ResponsePICOBOOT {
|
||||
struct Envelope {
|
||||
static constexpr int8_t ext_id = 0;
|
||||
uint32_t message_id;
|
||||
uint32_t checksum;
|
||||
std::vector<uint8_t> payload;
|
||||
auto as_tuple() const { return std::tie(message_id, checksum, payload); }
|
||||
auto as_tuple() { return std::tie(message_id, checksum, payload); }
|
||||
};
|
||||
|
||||
struct DeviceError {
|
||||
static constexpr int8_t ext_id = 1;
|
||||
auto as_tuple() const { return std::tie(); }
|
||||
auto as_tuple() { return std::tie(); }
|
||||
uint32_t code;
|
||||
std::string message;
|
||||
auto as_tuple() const { return std::tie(code, message); }
|
||||
auto as_tuple() { return std::tie(code, message); }
|
||||
};
|
||||
|
||||
struct RequestPICOBOOT {
|
||||
@@ -17,6 +28,12 @@ struct RequestPICOBOOT {
|
||||
auto as_tuple() { return std::tie(); }
|
||||
};
|
||||
|
||||
struct ResponsePICOBOOT {
|
||||
static constexpr int8_t ext_id = 3;
|
||||
auto as_tuple() const { return std::tie(); }
|
||||
auto as_tuple() { return std::tie(); }
|
||||
};
|
||||
|
||||
struct RequestInfo {
|
||||
static constexpr int8_t ext_id = 4;
|
||||
auto as_tuple() const { return std::tie(); }
|
||||
@@ -25,24 +42,8 @@ struct RequestInfo {
|
||||
|
||||
struct ResponseInfo {
|
||||
static constexpr int8_t ext_id = 5;
|
||||
std::array<uint8_t, 8> board_id;
|
||||
std::array<uint8_t, 6> mac;
|
||||
auto as_tuple() const { return std::tie(mac); }
|
||||
auto as_tuple() { return std::tie(mac); }
|
||||
};
|
||||
|
||||
struct DeviceError {
|
||||
static constexpr int8_t ext_id = 3;
|
||||
uint32_t code;
|
||||
std::string message;
|
||||
auto as_tuple() const { return std::tie(code, message); }
|
||||
auto as_tuple() { return std::tie(code, message); }
|
||||
};
|
||||
|
||||
struct Envelope {
|
||||
static constexpr int8_t ext_id = 0;
|
||||
uint32_t message_id;
|
||||
uint32_t checksum;
|
||||
std::vector<uint8_t> payload;
|
||||
auto as_tuple() const { return std::tie(message_id, checksum, payload); }
|
||||
auto as_tuple() { return std::tie(message_id, checksum, payload); }
|
||||
auto as_tuple() const { return std::tie(board_id, mac); }
|
||||
auto as_tuple() { return std::tie(board_id, mac); }
|
||||
};
|
||||
|
||||
@@ -2,12 +2,13 @@ package client
|
||||
|
||||
import "github.com/theater/picomap/lib/msgpack"
|
||||
|
||||
type ResponsePICOBOOT struct{}
|
||||
type RequestPICOBOOT struct{}
|
||||
type ResponsePICOBOOT struct{}
|
||||
|
||||
type RequestInfo struct{}
|
||||
type ResponseInfo struct {
|
||||
MAC [6]byte
|
||||
BoardID [8]byte
|
||||
MAC [6]byte
|
||||
}
|
||||
|
||||
type DeviceError struct {
|
||||
@@ -27,9 +28,9 @@ type Envelope struct {
|
||||
|
||||
func init() {
|
||||
msgpack.RegisterExt(0, (*Envelope)(nil))
|
||||
msgpack.RegisterExt(1, (*ResponsePICOBOOT)(nil))
|
||||
msgpack.RegisterExt(1, (*DeviceError)(nil))
|
||||
msgpack.RegisterExt(2, (*RequestPICOBOOT)(nil))
|
||||
msgpack.RegisterExt(3, (*DeviceError)(nil))
|
||||
msgpack.RegisterExt(3, (*ResponsePICOBOOT)(nil))
|
||||
msgpack.RegisterExt(4, (*RequestInfo)(nil))
|
||||
msgpack.RegisterExt(5, (*ResponseInfo)(nil))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <stdio.h>
|
||||
#include "pico/stdlib.h"
|
||||
#include "pico/bootrom.h"
|
||||
#include "pico/unique_id.h"
|
||||
#include "device.h"
|
||||
|
||||
extern "C" {
|
||||
@@ -25,6 +26,7 @@ static bool w6300_init() {
|
||||
|
||||
int main() {
|
||||
stdio_init_all();
|
||||
stdio_set_translate_crlf(&stdio_usb, false);
|
||||
|
||||
if (!w6300_init()) {
|
||||
printf("W6300 init failed\n");
|
||||
@@ -54,6 +56,9 @@ int main() {
|
||||
break;
|
||||
case RequestInfo::ext_id: {
|
||||
ResponseInfo info;
|
||||
pico_unique_board_id_t uid;
|
||||
pico_get_unique_board_id(&uid);
|
||||
std::copy(uid.id, uid.id + 8, info.board_id.begin());
|
||||
getSHAR(info.mac.data());
|
||||
send_bytes(encode_response(msg->message_id, info));
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user