178 } |
178 } |
179 json_object_put(jobj); |
179 json_object_put(jobj); |
180 |
180 |
181 msg = xstrcpy((char *)"{\"node\":\""); |
181 msg = xstrcpy((char *)"{\"node\":\""); |
182 msg = xstrcat(msg, edge_node); |
182 msg = xstrcat(msg, edge_node); |
183 msg = xstrcat(msg, (char *)"\",\"group\":\""); |
183 msg = xstrcat(msg, (char *)"\",\"group_id\":\""); |
184 msg = xstrcat(msg, group_id); |
184 msg = xstrcat(msg, group_id); |
185 msg = xstrcat(msg, (char *)"\",\"online\":"); |
185 msg = xstrcat(msg, (char *)"\",\"online\":"); |
186 msg = xstrcat(msg, node->online ? (char *)"1":(char *)"0"); |
186 msg = xstrcat(msg, node->online ? (char *)"1":(char *)"0"); |
|
187 msg = xstrcat(msg, (char *)",\"interval\":"); |
|
188 snprintf(buf, 73, "%d", node->interval); |
|
189 msg = xstrcat(msg, buf); |
|
190 if (node->hardwaremake) { |
|
191 msg = xstrcat(msg, (char *)",\"hardwaremake\":\""); |
|
192 msg = xstrcat(msg, node->hardwaremake); |
|
193 msg = xstrcat(msg, (char *)"\""); |
|
194 } |
|
195 if (node->hardwaremodel) { |
|
196 msg = xstrcat(msg, (char *)",\"hardwaremodel\":\""); |
|
197 msg = xstrcat(msg, node->hardwaremodel); |
|
198 msg = xstrcat(msg, (char *)"\""); |
|
199 } |
|
200 if (node->os) { |
|
201 msg = xstrcat(msg, (char *)",\"os\":\""); |
|
202 msg = xstrcat(msg, node->os); |
|
203 msg = xstrcat(msg, (char *)"\""); |
|
204 } |
|
205 if (node->os_version) { |
|
206 msg = xstrcat(msg, (char *)",\"os_version\":\""); |
|
207 msg = xstrcat(msg, node->os_version); |
|
208 msg = xstrcat(msg, (char *)"\""); |
|
209 } |
|
210 if (node->firmware) { |
|
211 msg = xstrcat(msg, (char *)",\"firmware\":\""); |
|
212 msg = xstrcat(msg, node->firmware); |
|
213 msg = xstrcat(msg, (char *)"\""); |
|
214 } |
187 msg = xstrcat(msg, (char *)",\"lastseen\":\""); |
215 msg = xstrcat(msg, (char *)",\"lastseen\":\""); |
188 mytime = localtime(&node->lastseen); |
216 mytime = localtime(&node->lastseen); |
189 snprintf(buf, 73, "%04d-%02d-%02d %02d:%02d:%02d", |
217 snprintf(buf, 73, "%04d-%02d-%02d %02d:%02d:%02d", |
190 mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec); |
218 mytime->tm_year + 1900, mytime->tm_mon + 1, mytime->tm_mday, mytime->tm_hour, mytime->tm_min, mytime->tm_sec); |
191 msg = xstrcat(msg, buf); |
219 msg = xstrcat(msg, buf); |
198 if (node->humidity) { |
226 if (node->humidity) { |
199 msg = xstrcat(msg, (char *)",\"humidity\":"); |
227 msg = xstrcat(msg, (char *)",\"humidity\":"); |
200 snprintf(buf, 64, "%.1f", node->humidity); |
228 snprintf(buf, 64, "%.1f", node->humidity); |
201 msg = xstrcat(msg, buf); |
229 msg = xstrcat(msg, buf); |
202 } |
230 } |
203 msg = xstrcat(msg, (char *)",\"ip\":\""); |
231 msg = xstrcat(msg, (char *)",\"net_ifname\":\""); |
|
232 msg = xstrcat(msg, node->net_ifname); |
|
233 msg = xstrcat(msg, (char *)"\",\"net_address\":\""); |
204 msg = xstrcat(msg, node->net_address); |
234 msg = xstrcat(msg, node->net_address); |
205 msg = xstrcat(msg, (char *)"\""); |
235 msg = xstrcat(msg, (char *)"\""); |
206 if (node->net_rssi != 0) { |
236 if (node->net_rssi != 0) { |
207 msg = xstrcat(msg, (char *)",\"rssi\":"); |
237 msg = xstrcat(msg, (char *)",\"net_rssi\":"); |
208 snprintf(buf, 64, "%d", node->net_rssi); |
238 snprintf(buf, 64, "%d", node->net_rssi); |
209 msg = xstrcat(msg, buf); |
239 msg = xstrcat(msg, buf); |
210 } |
240 } |
211 msg = xstrcat(msg, (char *)"}"); |
241 msg = xstrcat(msg, (char *)"}"); |
212 ws_broadcast(msg); |
242 ws_broadcast(msg); |