Added some basic command handling for the devices

This commit is contained in:
2025-12-22 23:06:33 +00:00
parent b3c3d4fbac
commit af3322bc9f
7 changed files with 176 additions and 50 deletions
+1 -7
View File
@@ -65,13 +65,6 @@ func (wt *WalkieTalkie) TurnOff() error {
return wt.Serial.Close()
}
// func (wt *WalkieTalkie) SendCommand(cmd Command, payload []byte) (int, error) {
// switch cmd {
// case CmdRequestID:
// return wt.RequestIdentification(d * serial.Port)
// }
// }
func (wt *WalkieTalkie) RequestIdentification() (int, error) {
return wt.Serial.Write([]byte{uint8(CmdRequestID)})
}
@@ -87,6 +80,7 @@ type header struct {
}
func (wt *WalkieTalkie) sendPacket(data any) error {
fmt.Println("Sending a packet...")
// Prepare the payload
var buf bytes.Buffer
err := binary.Write(&buf, binary.LittleEndian, data)