Documentation ¶
Overview ¶
Implements a Controller for the Phoscon ConBee II.
The serial protocol is documented here:
https://github.com/dresden-elektronik/deconz-serial-protocol
https://deconz.dresden-elektronik.de/raspbian/deCONZ-Serial-Protocol-en_1.21.pdf
Index ¶
- Variables
- func BeginPayload(buffer *bytes.Buffer) int
- func EndPayload(buffer *bytes.Buffer, pos int)
- func SerializeFrame(frame Frame) ([]byte, error)
- func WriteUint16(buffer *bytes.Buffer, value uint16)
- type CommandID
- type Controller
- type DeviceState
- type DeviceStateRequest
- type DeviceStateResponse
- type EnqueueSendDataRequest
- type EnqueueSendDataResponse
- type Frame
- type MACPollIndication
- type NetParam
- type NetworkState
- type ParsableCommand
- type ParsableMap
- type QuerySendDataRequest
- type QuerySendDataResponse
- type ReadFirmwareVersionRequest
- type ReadFirmwareVersionResponse
- type ReadParameterRequest
- type ReadParameterResponse
- type ReadReceivedDataRequest
- type ReadReceivedDataResponse
- type ReceivedDataNotification
- type SerializableCommand
- type Status
- type UpdateNeighborCommand
- type VersionNumber
- type WriteParameterRequest
- type WriteParameterResponse
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPacket = errors.New("invalid packet")
Functions ¶
func BeginPayload ¶
func EndPayload ¶
func SerializeFrame ¶
SerializeFrame converts a frame into a slice of bytes.
The frame length is computed automatically and the corresponding field from the frame object is ignored.
The command can be a SerializableCommand or a slice of bytes. If the command is a SerializableCommand the command ID is taken from the command.
func WriteUint16 ¶
Types ¶
type CommandID ¶
type CommandID byte
const ( CmdDeviceState CommandID = 0x07 CmdChangeNetworkState CommandID = 0x08 CmdReadParameter CommandID = 0x0A CmdWriteParameter CommandID = 0x0B CmdDeviceStateChanged CommandID = 0x0E CmdVersion CommandID = 0x0D CmdAPSDataRequest CommandID = 0x12 CmdAPSDataConfirm CommandID = 0x04 CmdAPSDataIndication CommandID = 0x17 CmdMACPollIndication CommandID = 0x1C CmdUpdateNeighbor CommandID = 0x1D CmdMACBeaconIndication CommandID = 0x1F CmdUpdateBootloader CommandID = 0x21 )
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func NewController ¶
func NewController(settings zigbee.ControllerSettings) (*Controller, error)
func (*Controller) Close ¶
func (c *Controller) Close() error
func (*Controller) PermitJoining ¶
func (c *Controller) PermitJoining(enabled bool) error
func (*Controller) Send ¶
func (c *Controller) Send(msg zigbee.OutgoingMessage) error
func (*Controller) SendCommand ¶
func (c *Controller) SendCommand(command SerializableCommand) error
func (*Controller) Start ¶
func (c *Controller) Start() (chan zigbee.IncomingMessage, error)
type DeviceState ¶
type DeviceState byte
const ( DeviceStateNetworkStateMask DeviceState = 0b0000_0011 DeviceStateDataConfirmFlag DeviceState = 0b0000_0100 DeviceStateDataIndicationFlag DeviceState = 0b0000_1000 DeviceStateConfigurationChangedFlag DeviceState = 0b0001_0000 DeviceStateDataRequestFreeSlotsFlag DeviceState = 0b0010_0000 )
func (DeviceState) NetworkState ¶
func (s DeviceState) NetworkState() NetworkState
func (DeviceState) String ¶
func (s DeviceState) String() string
type DeviceStateRequest ¶
type DeviceStateRequest struct{}
func (*DeviceStateRequest) CommandID ¶
func (r *DeviceStateRequest) CommandID() CommandID
func (*DeviceStateRequest) ParsePayload ¶
func (r *DeviceStateRequest) ParsePayload(data []byte) error
func (*DeviceStateRequest) SerializePayload ¶
func (r *DeviceStateRequest) SerializePayload(buffer *bytes.Buffer) error
type DeviceStateResponse ¶
type DeviceStateResponse struct {
State DeviceState
}
func (*DeviceStateResponse) CommandID ¶
func (r *DeviceStateResponse) CommandID() CommandID
func (*DeviceStateResponse) ParsePayload ¶
func (r *DeviceStateResponse) ParsePayload(data []byte) error
func (*DeviceStateResponse) SerializePayload ¶
func (r *DeviceStateResponse) SerializePayload(buffer *bytes.Buffer) error
type EnqueueSendDataRequest ¶
type EnqueueSendDataRequest struct { RequestID byte // Flags is not documented and should be set to 0. // When reading and Flags is not zero, the destination address is not valid. Flags byte Destination zigbee.Address DestinationEndpoint byte ProfileID uint16 ClusterID uint16 SourceEndpoint byte Payload []byte TxOptions byte Radius byte }
func (*EnqueueSendDataRequest) CommandID ¶
func (r *EnqueueSendDataRequest) CommandID() CommandID
func (*EnqueueSendDataRequest) ParsePayload ¶
func (r *EnqueueSendDataRequest) ParsePayload(data []byte) error
func (*EnqueueSendDataRequest) SerializePayload ¶
func (r *EnqueueSendDataRequest) SerializePayload(buffer *bytes.Buffer) error
type EnqueueSendDataResponse ¶
type EnqueueSendDataResponse struct { State DeviceState RequestID byte }
func (*EnqueueSendDataResponse) CommandID ¶
func (r *EnqueueSendDataResponse) CommandID() CommandID
func (*EnqueueSendDataResponse) ParsePayload ¶
func (r *EnqueueSendDataResponse) ParsePayload(data []byte) error
func (*EnqueueSendDataResponse) SerializePayload ¶
func (r *EnqueueSendDataResponse) SerializePayload(buffer *bytes.Buffer) error
type Frame ¶
type Frame struct { CommandID CommandID SequenceNumber uint8 Status Status FrameLength uint16 Command interface{} }
One frame of the Conbee serial protocol.
type MACPollIndication ¶
type MACPollIndication struct { Source zigbee.Address // LQI is the Link Quality Indication. LQI byte // RSSI is the Received Signal Strength Indication. RSSI int8 }
func (*MACPollIndication) CommandID ¶
func (r *MACPollIndication) CommandID() CommandID
func (*MACPollIndication) ParsePayload ¶
func (r *MACPollIndication) ParsePayload(data []byte) error
func (*MACPollIndication) SerializePayload ¶
func (r *MACPollIndication) SerializePayload(buffer *bytes.Buffer) error
type NetParam ¶
type NetParam byte
const ( NetParamMACAddress NetParam = 0x01 NetParamNWKPANID NetParam = 0x05 NetParamNWKAddress NetParam = 0x07 NetParamNWKExtendedPANID NetParam = 0x08 NetParamAPSDesignedCoordinator NetParam = 0x09 NetParamChannelMask NetParam = 0x0A NetParamAPSExtendedPANID NetParam = 0x0B NetParamTrustCenterAddress NetParam = 0x0E NetParamSecurityMode NetParam = 0x10 NetParamPredefinedNWKPANID NetParam = 0x15 NetParamNetworkKey NetParam = 0x18 NetParamLinkKey NetParam = 0x19 NetParamCurrentChannel NetParam = 0x1C NetParamProtocolVersion NetParam = 0x22 NetParamNWKUpdateID NetParam = 0x24 NetParamWatchdogTTL NetParam = 0x26 NetParamNWKFrameCounter NetParam = 0x27 )
type NetworkState ¶
type NetworkState byte
const ( NetworkStateOffline NetworkState = 0x00 NetworkStateJoining NetworkState = 0x01 NetworkStateConnected NetworkState = 0x02 NetworkStateLeaving NetworkState = 0x03 )
func (NetworkState) String ¶
func (s NetworkState) String() string
type ParsableCommand ¶
type ParsableMap ¶
type QuerySendDataRequest ¶
type QuerySendDataRequest struct{}
func (*QuerySendDataRequest) CommandID ¶
func (r *QuerySendDataRequest) CommandID() CommandID
func (*QuerySendDataRequest) ParsePayload ¶
func (r *QuerySendDataRequest) ParsePayload(data []byte) error
func (*QuerySendDataRequest) SerializePayload ¶
func (r *QuerySendDataRequest) SerializePayload(buffer *bytes.Buffer) error
type QuerySendDataResponse ¶
type QuerySendDataResponse struct { State DeviceState RequestID byte Destination zigbee.Address DestinationEndpoint byte SourceEndpoint byte ConfirmStatus byte }
func (*QuerySendDataResponse) CommandID ¶
func (r *QuerySendDataResponse) CommandID() CommandID
func (*QuerySendDataResponse) ParsePayload ¶
func (r *QuerySendDataResponse) ParsePayload(data []byte) error
func (*QuerySendDataResponse) SerializePayload ¶
func (r *QuerySendDataResponse) SerializePayload(buffer *bytes.Buffer) error
type ReadFirmwareVersionRequest ¶
type ReadFirmwareVersionRequest struct {
Reserved uint32
}
func (*ReadFirmwareVersionRequest) CommandID ¶
func (r *ReadFirmwareVersionRequest) CommandID() CommandID
func (*ReadFirmwareVersionRequest) ParsePayload ¶
func (r *ReadFirmwareVersionRequest) ParsePayload(data []byte) error
func (*ReadFirmwareVersionRequest) SerializePayload ¶
func (r *ReadFirmwareVersionRequest) SerializePayload(buffer *bytes.Buffer) error
type ReadFirmwareVersionResponse ¶
type ReadFirmwareVersionResponse struct {
Version VersionNumber
}
func (*ReadFirmwareVersionResponse) CommandID ¶
func (r *ReadFirmwareVersionResponse) CommandID() CommandID
func (*ReadFirmwareVersionResponse) ParsePayload ¶
func (r *ReadFirmwareVersionResponse) ParsePayload(data []byte) error
func (*ReadFirmwareVersionResponse) SerializePayload ¶
func (r *ReadFirmwareVersionResponse) SerializePayload(buffer *bytes.Buffer) error
type ReadParameterRequest ¶
type ReadParameterRequest struct {
ParameterID NetParam
}
func (*ReadParameterRequest) CommandID ¶
func (r *ReadParameterRequest) CommandID() CommandID
func (*ReadParameterRequest) ParsePayload ¶
func (r *ReadParameterRequest) ParsePayload(data []byte) error
func (*ReadParameterRequest) SerializePayload ¶
func (r *ReadParameterRequest) SerializePayload(buffer *bytes.Buffer) error
type ReadParameterResponse ¶
func (*ReadParameterResponse) CommandID ¶
func (r *ReadParameterResponse) CommandID() CommandID
func (*ReadParameterResponse) ParsePayload ¶
func (r *ReadParameterResponse) ParsePayload(data []byte) error
func (*ReadParameterResponse) SerializePayload ¶
func (r *ReadParameterResponse) SerializePayload(buffer *bytes.Buffer) error
type ReadReceivedDataRequest ¶
type ReadReceivedDataRequest struct {
Flags byte
}
func (*ReadReceivedDataRequest) CommandID ¶
func (r *ReadReceivedDataRequest) CommandID() CommandID
func (*ReadReceivedDataRequest) ParsePayload ¶
func (r *ReadReceivedDataRequest) ParsePayload(data []byte) error
func (*ReadReceivedDataRequest) SerializePayload ¶
func (r *ReadReceivedDataRequest) SerializePayload(buffer *bytes.Buffer) error
type ReadReceivedDataResponse ¶
type ReadReceivedDataResponse struct { State DeviceState Destination zigbee.Address DestinationEndpoint byte Source zigbee.Address SourceEndpoint byte ProfileID uint16 ClusterID uint16 // Payload is the APS frame payload. Payload []byte // LQI is the Link Quality Indication. LQI byte // RSSI is the Received Signal Strength Indication. RSSI int8 }
func (*ReadReceivedDataResponse) CommandID ¶
func (r *ReadReceivedDataResponse) CommandID() CommandID
func (*ReadReceivedDataResponse) ParsePayload ¶
func (r *ReadReceivedDataResponse) ParsePayload(data []byte) error
func (*ReadReceivedDataResponse) SerializePayload ¶
func (r *ReadReceivedDataResponse) SerializePayload(buffer *bytes.Buffer) error
type ReceivedDataNotification ¶
type ReceivedDataNotification struct {
State DeviceState
}
func (*ReceivedDataNotification) CommandID ¶
func (r *ReceivedDataNotification) CommandID() CommandID
func (*ReceivedDataNotification) ParsePayload ¶
func (r *ReceivedDataNotification) ParsePayload(data []byte) error
func (*ReceivedDataNotification) SerializePayload ¶
func (r *ReceivedDataNotification) SerializePayload(buffer *bytes.Buffer) error
type SerializableCommand ¶
type UpdateNeighborCommand ¶
type UpdateNeighborCommand struct { Action byte ShortAddress uint16 MACAddress zigbee.MACAddress }
UpdateNeighborCommand is experimental and not officially documented. See: https://github.com/dresden-elektronik/deconz-rest-plugin/issues/665#issuecomment-401341502
func (*UpdateNeighborCommand) CommandID ¶
func (c *UpdateNeighborCommand) CommandID() CommandID
func (*UpdateNeighborCommand) ParsePayload ¶
func (c *UpdateNeighborCommand) ParsePayload(data []byte) error
func (*UpdateNeighborCommand) SerializePayload ¶
func (c *UpdateNeighborCommand) SerializePayload(buffer *bytes.Buffer) error
type VersionNumber ¶
type VersionNumber uint32
func (VersionNumber) String ¶
func (v VersionNumber) String() string
type WriteParameterRequest ¶
func (*WriteParameterRequest) CommandID ¶
func (r *WriteParameterRequest) CommandID() CommandID
func (*WriteParameterRequest) ParsePayload ¶
func (r *WriteParameterRequest) ParsePayload(data []byte) error
func (*WriteParameterRequest) SerializePayload ¶
func (r *WriteParameterRequest) SerializePayload(buffer *bytes.Buffer) error
type WriteParameterResponse ¶
type WriteParameterResponse struct {
ParameterID NetParam
}
func (*WriteParameterResponse) CommandID ¶
func (r *WriteParameterResponse) CommandID() CommandID
func (*WriteParameterResponse) ParsePayload ¶
func (r *WriteParameterResponse) ParsePayload(data []byte) error
func (*WriteParameterResponse) SerializePayload ¶
func (r *WriteParameterResponse) SerializePayload(buffer *bytes.Buffer) error