aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2013-09-19 00:24:11 -0400
committerMike Crute <mcrute@gmail.com>2013-09-19 00:24:11 -0400
commitda6d833f8a2d09104dda88925fbf07476159f54f (patch)
treed9087d7d23559229668d47caeb7c160a2629ee16
parent9503ffd82cc45af3c44f9ecf4574f79ab52153bd (diff)
downloadubntmfi-da6d833f8a2d09104dda88925fbf07476159f54f.tar.bz2
ubntmfi-da6d833f8a2d09104dda88925fbf07476159f54f.tar.xz
ubntmfi-da6d833f8a2d09104dda88925fbf07476159f54f.zip
Update notes
-rw-r--r--.gitignore1
-rw-r--r--inform_protocol.txt107
2 files changed, 102 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 0d20b64..e07a3b2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
1*.pyc 1*.pyc
2.sandbox_name
diff --git a/inform_protocol.txt b/inform_protocol.txt
index 2a846a5..50c1b20 100644
--- a/inform_protocol.txt
+++ b/inform_protocol.txt
@@ -10,11 +10,17 @@ disable.
10Everything appears to be pull-based, even provisioning. This makes sense with 10Everything appears to be pull-based, even provisioning. This makes sense with
11the cloud controller where the controller has no access to your network. I 11the cloud controller where the controller has no access to your network. I
12haven't documented yet how anything works within the protocol, that's next. 12haven't documented yet how anything works within the protocol, that's next.
13This documents the overall procol itself. 13This documents the overall protocol itself.
14 14
15The device will inform by executing an HTTP POST with an encrypted payload to
16http://controller:6080/inform at a regular interval (default is 10 seconds) and
17will expect an encrypted payload to be returned. If the device gets a command
18response instead of a noop response it will immediately do another inform; this
19continues until the controller sends the next noop response. Responses never
20appear to contain multiple commands.
15 21
16Packet Structure 22Raw Packet Structure
17---------------- 23--------------------
184 bytes magic number integer 244 bytes magic number integer
194 bytes version integer 254 bytes version integer
206 bytes hwaddr string 266 bytes hwaddr string
@@ -24,20 +30,109 @@ Packet Structure
244 bytes data length integer 304 bytes data length integer
25n bytes encrypted payload string 31n bytes encrypted payload string
26 32
27 33Raw Packet Constraints
34----------------------
28magic must == 1414414933 35magic must == 1414414933
29data version must < 1 36data version must < 1
30flags & 0x1 != 0 means encrypted 37flags & 0x1 != 0 means encrypted
31flags & 0x2 != 0 means compressed 38flags & 0x2 != 0 means compressed
32 39
33 40Payload Types
41-------------
34The payload is AES encrypted in CBC mode using PKCS5 padding. They key is the 42The payload is AES encrypted in CBC mode using PKCS5 padding. They key is the
35device auth key from the database or a master key that is hard coded if the 43device auth key from the database or a master key that is hard coded if the
36device hasn't been provisioned yet. The master key is hard coded in the 44device hasn't been provisioned yet. The master key is hard coded in the
37controller code in the DeviceManager class and pretty easy to find. 45controller code in the DeviceManager class and pretty easy to find.
38 46
47MASTER_KEY = "ba86f2bbe107c7c57eb5f2690775c712"
48
39On devices running protocol version 1 the encrypted payload is just JSON data. 49On devices running protocol version 1 the encrypted payload is just JSON data.
40In version 0 of the protocol the data was key=value pairs separated by 50In version 0 of the protocol the data was key=value pairs separated by
41newlines. All of the mFi hardware I have access to uses protocol version 1. 51newlines. All of the mFi hardware I have access to uses protocol version 1.
42 52
43MASTER_KEY = "ba86f2bbe107c7c57eb5f2690775c712" 53The payloads break down into two categories; those coming into the controller
54and those going out of the controller.
55
56Output Payloads
57---------------
58Output payloads are those that originate from the controller and are bound for
59the device. These always appear to contain a _type field. I have observed the
60following output payloads.
61
62 _type: firmware upgrade (upgrade)
63 url: full url to firmware.bin
64 datetime: rfc3339 formatted date, server time
65 server_time_in_utc: server time in UTC as a unix timestamp (string)
66 version: firmware version (string)
67 time: server time as unix timestamp (int)
68 _id: unknown id string (5232701de4b0457a2f2f031f)
69 device_id: device ID from mongodb
70
71 _type: config update (setparam)
72 port_cfg: configuration for ports as string
73 server_time_in_utc: server time in UTC as a unix timestamp (string)
74
75
76 _type: reboot (reboot)
77 datetime: rfc3339 formatted date, server time
78 device_id: device ID from mongodb
79
80 _type: heartbeat (noop)
81 interval: next checkin time in seconds (integer)
82
83 _type: command (cmd)
84 _admin: admin data object
85 _id: mongodb id of admin
86 lang: admin language (en_US)
87 name: admin username
88 x_password: admin password
89 _id: unknown id string (5232701de4b0457a2f2f031f)
90 datetime: rfc3339 formatted date, server time
91 server_time_in_utc: server time in UTC as a unix timestamp (string)
92 time: server time as unix timestamp (int)
93 device_id: device ID from mongodb
94 cmd: command to use (mfi-output)
95 mac: device mac address
96 model: device model (Outlet for mPower)
97 off_volt: ?? (int)
98 port: device port to update (int)
99 sId: sensor ID
100 timer: ?? (int)
101 val: output value (int)
102 volt: ?? (int)
103
104 // val and volt set to 1 to turn on, 0 to turn off
105
106
107Input Payloads
108--------------
109Incoming packets appear to be a JSON version of the out put of the `mca-dump`
110command on the device. There is definitely some AirOS legacy in here. I don't
111document the whole input payload since most of it isn't interesting.
112
113 callback from device: javascript object
114 alarm: list of sensors
115 index: port name
116 sId: sensor ID hash
117 time: device time
118
119 // For mPort Only
120 tag: kind of reading presented (magnetic, temperature, humidity)
121 type: kind of device (input, analog, output)
122 val: value (float)
123
124 // For mPower Only
125 entries: list of entry objects
126 tag: kind of reading (output, pf, energy_sum, v_rms, i_rms, active_pwr)
127 type: sensor type (output, analog, rmsSum, rms)
128 val: value (float)
129
130 hostname: hostname of device ("ubnt" unless changed)
131 ip: IP of device
132 mac: mac address of primary interface
133 mfi: boolean, indicates if an mfi device
134 model: device model name
135 model_display: display name for device
136 serial: device serial number
137 uptime: uptime in seconds since last reboot
138 version: firmware version