Move the communication stuff to its own package

This commit is contained in:
2025-12-14 15:24:51 +00:00
parent c23441908f
commit 3ffad42922
4 changed files with 45 additions and 36 deletions
+6 -5
View File
@@ -1,6 +1,7 @@
package peripheral
import (
comm "esdi/peripheral/communication"
"esdi/peripheral/devices"
"time"
@@ -36,18 +37,18 @@ func (s PeripheralDeviceState) String() string {
type PeripheralDevice struct {
State PeripheralDeviceState
CommState CommState
CommState comm.CommState
ID uint8
Name string
WT *WalkieTalkie
WT *comm.WalkieTalkie
DeviceAPI *devices.Device
}
func NewPeripheralDevice(port string) *PeripheralDevice {
return &PeripheralDevice{
State: StateUnknown,
CommState: CommOff,
WT: &WalkieTalkie{
CommState: comm.CommOff,
WT: &comm.WalkieTalkie{
Cfg: &serial.Config{
Name: port,
Baud: 115200,
@@ -92,7 +93,7 @@ func (p *PeripheralDevice) Probe() error {
func (p *PeripheralDevice) ToConnectedIdling() {
p.State = StateConnected
p.CommState = CommIdle
p.CommState = comm.CommIdle
}
func (p *PeripheralDevice) Merge(packet *IdentificationPacket) {