Documentation
¶
Overview ¶
Package wire defines the JSON envelopes exchanged on the AmpliFi control WebSocket. They mirror MethodRequest/AllJoynRequest and WSMessage in the decompiled app.
Index ¶
Constants ¶
const ( IfaceAuth = IfacePrefix + "Auth" IfaceFingerprint = IfacePrefix + "ClusterNode.fingerprint" )
Interface names used internally, as sent in the "iface" field. The public set is amplifi.Iface*.
const IfacePrefix = "com.ubnt.UnifiHome."
IfacePrefix is the common prefix of the AllJoyn interface names.
Variables ¶
var ( // MsgpackNull is a msgpack nil, the argument the app passes to getters // such as GetWifiClientCount. MsgpackNull = []byte{0xc0} // MsgpackTwoNulls is a msgpack [nil, nil], the app's packArrayOfTwoNulls. MsgpackTwoNulls = []byte{0x92, 0xc0, 0xc0} )
Functions ¶
func ClusterNodeArg ¶
ClusterNodeArg wraps a ClusterNode setter payload the way the app's packClusterNode does: [{LastUpdateTimestamp: now in µs}, payload].
func ClusterNodePayload ¶
ClusterNodePayload extracts the payload map from a ClusterNode getter result, which is [cluster metadata, payload] (ClusterNodeArray).
func DecodeMsgpack ¶
DecodeMsgpack decodes a msgpack payload into plain Go values. Maps become map[string]any whatever their key type: integer option codes become their decimal string ("1"), and binary keys (such as the 6 byte MACs keying a peer list) become a string of the raw bytes. This mirrors the app, which looks up option codes as strings, and avoids []byte keys that Go maps cannot hold.
func EncodeMsgpack ¶
EncodeMsgpack encodes v the way the app's MsgPackBase.serializeToMsgPack does, as the inverse of DecodeMsgpack: map keys that are decimal numbers are packed as integers (option codes), other keys as strings; []byte is packed as binary and integers in their most compact form.
Types ¶
type Request ¶
type Request struct {
Type string `json:"type"`
Iface string `json:"iface"`
SeqID int `json:"seqId"`
Method string `json:"method,omitempty"`
Property string `json:"property,omitempty"`
Payload map[string]any `json:"payload,omitempty"`
}
Request is the JSON envelope for a method call (Type "call") or a property access (Type "getProperty" or "setProperty").
type Response ¶
type Response struct {
Type string `json:"type"`
Iface string `json:"iface"`
SeqID int `json:"seqId"`
Signal string `json:"signal"`
Payload map[string]any `json:"payload"`
}
Response is the JSON envelope the router returns, either a reply to a call or an unsolicited signal.
func (Response) DecodeMsgpack ¶
DecodeMsgpack decodes payload.msgpack (see DecodeMsgpack). It returns nil when the payload carries no msgpack or an empty one.
func (Response) IsResponse ¶
IsResponse reports whether r is a reply to a call.