Repository navigation
Expand file tree
/
Copy pathhost-api-profile.json
More file actions
235 lines (235 loc) · 7.81 KB
/
Copy pathhost-api-profile.json
File metadata and controls
235 lines (235 loc) · 7.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
{
"schema_version": "sourceful.host-api-profile/v1",
"description": "What a canonical driver in this repository may call. One driver per device, one source of truth, running on linux-edge hosts.",
"canonical_reference": {
"source": "srcfl/blixt-gateway l1/drivers/skeleton.lua",
"note": "Blixt L1 is the naming and structure reference. Its host API states endianness in the name, gives identification its own setters, and provides string decoding instead of leaving every driver to loop over registers itself. FTW is the more malleable host, so where the two disagree the Blixt spelling is the target and FTW adapts. A driver compiled for another target later, including Zap, must not need rewriting to get there."
},
"targets": {
"ftw-core": "linux-edge",
"blixt-l1": "linux-edge"
},
"profiles": {
"linux-edge": {
"description": "FTW (gopher-lua) and Blixt L1 (luajit). Both run on Linux-class hardware, so a driver here is not written to a memory budget. The function list is FTW's actual surface, read from its Go binding rather than assumed.",
"functions": {
"identify": [
"set_make",
"set_model",
"set_sn",
"set_rated_w",
"set_warmup_s"
],
"core": [
"emit",
"emit_metric",
"log",
"now_ms",
"sleep",
"set_device_fault",
"set_poll_interval",
"millis",
"set_watchdog_timeout_s",
"persist_secret",
"unix_ms",
"reserve_vehicle_wake",
"site_location"
],
"decode": [
"decode_i16",
"decode_u16",
"decode_i32_be",
"decode_i32_le",
"decode_u32_be",
"decode_u32_le",
"decode_f32_be",
"decode_u64",
"decode_string",
"scale"
],
"modbus": [
"modbus_read",
"write",
"write_registers",
"write_fc06"
],
"mqtt": [
"mqtt_messages",
"mqtt_publish",
"mqtt_subscribe"
],
"http": [
"http_get",
"http_post",
"http_patch",
"http_request",
"http_cookies_clear",
"https_get",
"https_post",
"json_decode"
],
"serial": [
"serial_available",
"serial_read"
],
"net": [
"udp_recv",
"udp_send"
],
"ble": [
"ble_connect",
"ble_disconnect",
"ble_notifications",
"ble_read",
"ble_scan",
"ble_subscribe",
"ble_write"
],
"crypto": [
"aes_gcm_decrypt"
],
"transport": [
"http_get",
"http_post",
"http_patch",
"http_request",
"http_cookies_clear",
"mqtt_pub",
"mqtt_publish",
"mqtt_sub",
"mqtt_subscribe",
"mqtt_messages",
"tcp_open",
"tcp_close",
"tcp_is_open",
"tcp_recv",
"ws_open",
"ws_close",
"ws_is_open",
"ws_send",
"ws_messages",
"serial_read"
],
"data": [
"json_encode",
"json_decode",
"aes_gcm_decrypt"
]
}
}
},
"deprecated": {
"description": "Two dialects, not a right and a wrong one. FTW's host spells these the way its Go binding always has; Blixt L1 spells them the other way. Both are real host APIs on shipping hardware, so a driver written for either is valid here. A host that wants to run the other dialect's drivers adds aliases -- FTW did exactly that in v1.11.4-beta.7, in about thirty lines. Converting drivers to a single spelling was tried and abandoned: it changed 196 lines across 36 field-proven drivers without changing what any of them does.",
"ftw_to_blixt": {
"modbus_write": "write",
"modbus_write_multiple": "write_registers",
"modbus_write_multi": "write_registers",
"decode_u32": "decode_u32_be",
"decode_i32": "decode_i32_be",
"decode_f32": "decode_f32_be",
"millis": "now_ms"
}
},
"pending": {
"description": "Called by FTW's bundled drivers and not part of the contract. Importing a bundled driver that needs one requires deciding first: define it for every linux-edge host, or rewrite the driver without it.",
"functions": [
"json_encode",
"mqtt_pub",
"persist_secret",
"serial_write",
"set_watchdog_timeout_s",
"tcp_close",
"tcp_is_open",
"tcp_open",
"tcp_recv",
"ws_close",
"ws_is_open",
"ws_messages",
"ws_open",
"ws_send"
]
},
"emit_keys": {
"description": "Blixt reads each emit table by exact key name and silently drops a key whose case is wrong, so these are a contract rather than a convention. They match @srcful/data-models verbatim. The catalog grew lowercase names instead; both are counted as debt until drivers are converted.",
"canonical": {
"battery": [
"W",
"V",
"A",
"SoC_nom_fract",
"temperature_C",
"total_charge_Wh",
"total_discharge_Wh",
"available_charge_Wh",
"available_discharge_Wh",
"available_charge_W",
"available_discharge_W",
"setpoint_w",
"control_power_w",
"control_power_available",
"control_power_observed_at"
],
"inverter": [
"W",
"VA",
"Hz",
"L1_V",
"L1_A",
"L1_W",
"L2_V",
"L2_A",
"L2_W",
"L3_V",
"L3_A",
"L3_W",
"rated_W",
"available_import_W",
"available_export_W"
],
"pv": [
"W",
"total_generation_Wh",
"mppts",
"control_power_available"
],
"meter": [
"W",
"Hz",
"L1_V",
"L1_A",
"L1_W",
"L2_V",
"L2_A",
"L2_W",
"L3_V",
"L3_A",
"L3_W",
"total_import_Wh",
"total_export_Wh",
"power_origin",
"control_power_available"
],
"ev": [
"control_power_available",
"control_power_observed_at",
"control_power_confirmed",
"device_limit_a",
"device_limit_age_s"
]
},
"repeating_structures": "A repeating structure is a plural-named array, not numbered keys. pv.mppts is a list of {V, A, W} whose length is what the device physically has. The catalog's mppt1_v/mppt2_v cannot represent a four-MPPT inverter at all.",
"no_canonical_schema_yet": {
"der_types": [
"v2x_charger"
],
"reason": "@srcful/data-models has no agreed v2x_charger shape, and Blixt has no v2x driver to take the naming from. The 13 chargers here keep the short keys until one exists; guessing a schema would be worse than saying it is undecided."
},
"streams_vs_ders": "inverter is an emit STREAM, not a DER type: a battery or hybrid driver reports its AC stage (W, per-phase, rated_W, available_import_W / available_export_W headroom) on host.emit(\"inverter\", ...) while the device itself is declared as ders: [battery] (or [battery, pv]). Blixt L1 feeds the headroom keys into its arbitrator clamp and reads them by exact name \u2014 they have no lowercase fallback."
},
"write_result_semantics": {
"ftw-core": "returns error string on failure, nothing on success; never raises",
"blixt-l1": "returns true on success; raises (mlua error) on Modbus exception/timeout",
"portable_check": "local ok, res = pcall(host.write, a, v); failed = (not ok) or (res ~= nil and res ~= true)",
"note": "host.write is FC06 on ftw-core but FC16(count=1) on blixt-l1 (Deye ignores FC06 on some ranges); blixt-l1 adds host.write_fc06 for true FC06."
}
}