b4f922a0252cbda11e20600f562ac91705e6601f
[apps/hvac.git] / binding / hvac-demo-binding.c
1 /*
2  * Copyright (C) 2015, 2016 "IoT.bzh"
3  * Copyright (C) 2016 Konsulko Group
4  * Author "Romain Forlot"
5  * Author "Jose Bolo"
6  * Author "Scott Murray <scott.murray@konsulko.com>"
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 #define _GNU_SOURCE
21
22 #include <stdio.h>
23 #include <string.h>
24 #include <stdbool.h>
25 #include <unistd.h>
26 #include <sys/types.h>
27 #include <sys/socket.h>
28 #include <sys/ioctl.h>
29 #include <net/if.h>
30 #include <linux/can.h>
31 #include <math.h>
32
33 #include <json-c/json.h>
34
35 #define AFB_BINDING_VERSION 2
36 #define RED "/sys/class/leds/blinkm-3-9-red/brightness"
37 #define BLUE "/sys/class/leds/blinkm-3-9-blue/brightness"
38 #define GREEN "/sys/class/leds/blinkm-3-9-green/brightness"
39 #include <afb/afb-binding.h>
40
41 #define CAN_DEV "vcan0"
42
43 #ifndef NULL
44 #define NULL 0
45 #endif
46
47 static const struct afb_binding_interface *interface;
48 static struct afb_event event;
49
50 /*****************************************************************************************/
51 /*****************************************************************************************/
52 /**                                                                                     **/
53 /**                                                                                     **/
54 /**        SECTION: UTILITY FUNCTIONS                                                   **/
55 /**                                                                                     **/
56 /**                                                                                     **/
57 /*****************************************************************************************/
58 /*****************************************************************************************/
59
60 /*
61  * @brief Retry a function 3 times
62  *
63  * @param int function(): function that return an int wihtout any parameter
64  *
65  * @ return : 0 if ok, -1 if failed
66  *
67  */
68 static int retry( int(*func)())
69 {
70         int i;
71
72         for (i=0;i<4;i++)
73         {
74                 if ( (*func)() >= 0)
75                 {
76                         return 0;
77                 }
78                 usleep(100000);
79         }
80         return -1;
81 }
82
83 /*****************************************************************************************/
84 /*****************************************************************************************/
85 /**                                                                                     **/
86 /**                                                                                     **/
87 /**        SECTION: HANDLE CAN DEVICE                                                   **/
88 /**                                                                                     **/
89 /**                                                                                     **/
90 /*****************************************************************************************/
91 /*****************************************************************************************/
92
93 // Initialize CAN hvac array that will be sent trough the socket
94 static struct {
95         const char *name;
96         uint8_t value;
97 } hvac_values[] = {
98         { "LeftTemperature", 21 },
99         { "RightTemperature", 21 },
100         { "Temperature", 21 },
101         { "FanSpeed", 0 },
102         { "ACEnabled", 0 },
103         { "LeftLed", 15 },
104         { "RightLed", 15 }
105 };
106
107 // Holds RGB combinations for each temperature
108 static struct {
109         const int temperature;
110         const int rgb[3];
111 } degree_colours[] = {
112         {15, {0, 0, 229} },
113         {16, {22, 0, 204} },
114         {17, {34, 0, 189} },
115         {18, {46, 0, 175} },
116         {19, {58, 0, 186} },
117         {20, {70, 0, 146} },
118         {21, {82, 0, 131} },
119         {22, {104, 0, 116} },
120         {23, {116, 0, 102} },
121         {24, {128, 0, 87} },
122         {25, {140, 0, 73} },
123         {26, {152, 0, 58} },
124         {27, {164, 0, 43} },
125         {28, {176, 0, 29} },
126         {29, {188, 0, 14} },
127         {30, {201, 0, 5} }
128 };
129
130 struct can_handler {
131         int socket;
132         bool simulation;
133         char *send_msg;
134         struct sockaddr_can txAddress;
135 };
136
137 static struct can_handler can_handler = { .socket = -1, .simulation = false, .send_msg = "SENDING CAN FRAME"};
138
139 static int open_can_dev_helper()
140 {
141         struct ifreq ifr;
142
143         AFB_DEBUG("CAN Handler socket : %d", can_handler.socket);
144         close(can_handler.socket);
145
146         can_handler.socket = socket(PF_CAN, SOCK_RAW, CAN_RAW);
147         if (can_handler.socket < 0)
148         {
149                 AFB_ERROR("socket could not be created");
150         }
151         else
152         {
153                 // Attempts to open a socket to CAN bus
154                 strcpy(ifr.ifr_name, CAN_DEV);
155                 if(ioctl(can_handler.socket, SIOCGIFINDEX, &ifr) < 0)
156                 {
157                         AFB_ERROR("ioctl failed");
158                 }
159                 else
160                 {
161                         can_handler.txAddress.can_family = AF_CAN;
162                         can_handler.txAddress.can_ifindex = ifr.ifr_ifindex;
163
164                         // And bind it to txAddress
165                         if (bind(can_handler.socket, (struct sockaddr *)&can_handler.txAddress, sizeof(can_handler.txAddress)) < 0)
166                         {
167                                 AFB_ERROR("bind failed");
168                         }
169                         else {
170                                 return 0;
171                         }
172                 }
173                 close(can_handler.socket);
174                 can_handler.socket = -1;
175         }
176         return -1;
177 }
178
179 static int open_can_dev()
180 {
181         int rc = retry(open_can_dev_helper);
182         if(rc < 0)
183         {
184                 AFB_ERROR("Open of interface %s failed. Falling back to simulation mode", CAN_DEV);
185                 can_handler.socket = 0;
186                 can_handler.simulation = true;
187                 can_handler.send_msg = "FAKE CAN FRAME";
188                 rc = 0;
189         }
190         return rc;
191 }
192
193 // Get original get temperature function from cpp hvacplugin code
194 static uint8_t to_can_temp(uint8_t value)
195 {
196         int result = ((0xF0 - 0x10) / 15) * (value - 15) + 0x10;
197         if (result < 0x10)
198                 result = 0x10;
199         if (result > 0xF0)
200                 result = 0xF0;
201
202         return (uint8_t)result;
203 }
204
205 static uint8_t read_temp_left_zone()
206 {
207         return hvac_values[0].value;
208 }
209
210 static uint8_t read_temp_right_zone()
211 {
212         return hvac_values[1].value;
213 }
214
215 static uint8_t read_temp_left_led()
216 {
217         return hvac_values[5].value;
218 }
219
220 static uint8_t read_temp_right_led()
221 {
222         return hvac_values[6].value;
223 }
224
225 static uint8_t read_temp()
226 {
227         return (uint8_t)(((int)read_temp_left_zone() + (int)read_temp_right_zone()) >> 1);
228 }
229
230 static uint8_t read_fanspeed()
231 {
232         return hvac_values[3].value;
233 }
234
235 /* 
236  * @brief Writing to LED for both temperature sliders
237  */
238
239 static int temp_write_led()
240 {
241         int rc = 0, red_flag, blue_flag, green_flag, red_value, green_value, blue_value;
242         int right_temp;
243         int left_temp;
244
245         // /sys/class/leds/blinkm-3-9-red/brightness
246         FILE* r = fopen(RED, "w");
247         if (r == NULL) {
248                 AFB_ERROR("Unable to open RED path for writing");
249                 red_flag = 1;
250         }
251
252         // /sys/class/leds/blinkm-3-9-green/brightness
253         FILE* g = fopen(GREEN, "w");
254         if (g == NULL) {
255                 AFB_ERROR("Unable to open GREEN path for writing");
256                 green_flag = 1;
257         }
258
259         // /sys/class/leds/blinkm-3-9-blue/brightness
260         FILE* b = fopen(BLUE, "w");
261         if (b == NULL) {
262                 AFB_ERROR("Unable to open BLUE path for writing");
263                 blue_flag = 1;
264         }
265
266         if (red_flag || green_flag || blue_flag)
267         {
268                 rc = 1;
269         }
270
271         left_temp = read_temp_left_led() - 15;
272         right_temp = read_temp_right_led() - 15;
273
274         // Calculates average colour value taken from the temperature toggles
275         red_value = (degree_colours[left_temp].rgb[0] + degree_colours[right_temp].rgb[0]) / 2;
276         green_value = (degree_colours[left_temp].rgb[1] + degree_colours[right_temp].rgb[1]) / 2;
277         blue_value = (degree_colours[left_temp].rgb[2] + degree_colours[right_temp].rgb[2]) / 2;
278
279         // Writes to LED file the specific colour
280         fprintf(r, "%d", red_value);
281         fprintf(g, "%d", green_value);
282         fprintf(b, "%d", blue_value);
283         fclose(r);
284         fclose(g);
285         fclose(b);
286         return rc;
287
288 }
289
290 /*
291  * @brief Get temperature of left toggle in HVAC system
292  *
293  * @param struct afb_req : an afb request structure
294  *
295  */
296 static void temp_left_zone_led(struct afb_req request)
297 {
298         int i = 5, rc, x, changed;
299         double d;
300         struct json_object *query, *val;
301         uint8_t values[sizeof hvac_values / sizeof *hvac_values];
302         uint8_t saves[sizeof hvac_values / sizeof *hvac_values];
303
304         AFB_WARNING("In temp_left_zone_led.");
305
306         query = afb_req_json(request);
307
308         /* records initial values */
309         AFB_WARNING("Records initial values");
310         values[i] = saves[i] = hvac_values[i].value;
311
312
313         if (json_object_object_get_ex(query, hvac_values[i].name, &val))
314         {
315                 AFB_WARNING("Value of values[i] = %d", values[i]);
316                 AFB_WARNING("We got it. Tests if it is an int or double.");
317                 if (json_object_is_type(val, json_type_int)) {
318                         x = json_object_get_int(val);
319                         AFB_WARNING("We get an int: %d",x);
320                 }
321                 else if (json_object_is_type(val, json_type_double)) {
322                         d = json_object_get_double(val);
323                         x = (int)round(d);
324                         AFB_WARNING("We get a double: %f => %d",d,x);
325                 }
326                 else {
327                         afb_req_fail_f(request, "bad-request",
328                                 "argument '%s' isn't integer or double", hvac_values[i].name);
329                         return;
330                 }
331                 if (x < 0 || x > 255)
332                 {
333                         afb_req_fail_f(request, "bad-request",
334                                 "argument '%s' is out of bounds", hvac_values[i].name);
335                         return;
336                 }
337                 if (values[i] != x) {
338                         values[i] = (uint8_t)x;
339                         changed = 1;
340                         AFB_WARNING("%s changed to %d", hvac_values[i].name,x);
341                 }
342         }
343         else {
344                 AFB_WARNING("%s not found in query!",hvac_values[i].name);
345         }
346
347
348         if (changed) {
349                 hvac_values[i].value = values[i]; // update structure at line 102
350                 AFB_WARNING("WRITE_LED: value: %d", hvac_values[i].value);
351                 rc = temp_write_led();
352                 if (rc >= 0)
353                         afb_req_success(request, NULL, NULL);
354                 else if (retry(temp_write_led)) {
355                         /* restore initial values */
356                         hvac_values[i].value = saves[i];
357                         afb_req_fail(request, "error", "I2C error");
358                 }
359         }
360 }
361
362 /*
363  * @brief Get temperature of right toggle in HVAC system
364  *
365  * @param struct afb_req : an afb request structure
366  *
367  */
368 static void temp_right_zone_led(struct afb_req request)
369 {
370         int i = 6, rc, x, changed;
371         double d;
372         struct json_object *query, *val;
373         uint8_t values[sizeof hvac_values / sizeof *hvac_values];
374         uint8_t saves[sizeof hvac_values / sizeof *hvac_values];
375
376         AFB_WARNING("In temp_right_zone_led.");
377
378         query = afb_req_json(request);
379
380         /* records initial values */
381         AFB_WARNING("Records initial values");
382         values[i] = saves[i] = hvac_values[i].value;
383
384
385         if (json_object_object_get_ex(query, hvac_values[i].name, &val))
386         {
387                 AFB_WARNING("Value of values[i] = %d", values[i]);
388                 AFB_WARNING("We got it. Tests if it is an int or double.");
389                 if (json_object_is_type(val, json_type_int)) {
390                         x = json_object_get_int(val);
391                         AFB_WARNING("We get an int: %d",x);
392                 }
393                 else if (json_object_is_type(val, json_type_double)) {
394                         d = json_object_get_double(val);
395                         x = (int)round(d);
396                         AFB_WARNING("We get a double: %f => %d",d,x);
397                 }
398                 else {
399                         afb_req_fail_f(request, "bad-request",
400                                 "argument '%s' isn't integer or double", hvac_values[i].name);
401                         return;
402                 }
403                 if (x < 0 || x > 255)
404                 {
405                         afb_req_fail_f(request, "bad-request",
406                                 "argument '%s' is out of bounds", hvac_values[i].name);
407                         return;
408                 }
409                 if (values[i] != x) {
410                         values[i] = (uint8_t)x;
411                         changed = 1;
412                         AFB_WARNING("%s changed to %d", hvac_values[i].name,x);
413                 }
414         }
415         else {
416                 AFB_WARNING("%s not found in query!", hvac_values[i].name);
417         }
418
419
420         if (changed) {
421                 hvac_values[i].value = values[i]; // update structure at line 102
422                 AFB_WARNING("WRITE_LED: value: %d", hvac_values[i].value);
423                 rc = temp_write_led();
424                 if (rc >= 0)
425                         afb_req_success(request, NULL, NULL);
426                 else if (retry(temp_write_led)) {
427                         /* restore initial values */
428                         hvac_values[i].value = saves[i];
429                         afb_req_fail(request, "error", "I2C error");
430                 }
431         }
432 }
433
434 static int write_can()
435 {
436         struct can_frame txCanFrame;
437         int rc = 0;
438
439         rc = can_handler.socket;
440         if (rc >= 0)
441         {
442                 // Hardcoded can_id and dlc (data lenght code)
443                 txCanFrame.can_id = 0x30;
444                 txCanFrame.can_dlc = 8;
445                 txCanFrame.data[0] = to_can_temp(read_temp_left_zone());
446                 txCanFrame.data[1] = to_can_temp(read_temp_right_zone());
447                 txCanFrame.data[2] = to_can_temp(read_temp());
448                 txCanFrame.data[3] = 0xf0;
449                 txCanFrame.data[4] = read_fanspeed();
450                 txCanFrame.data[5] = 1;
451                 txCanFrame.data[6] = 0;
452                 txCanFrame.data[7] = 0;
453
454                 AFB_DEBUG("%s: %d %d [%02x %02x %02x %02x %02x %02x %02x %02x]\n",
455                         can_handler.send_msg,
456                         txCanFrame.can_id, txCanFrame.can_dlc,
457                         txCanFrame.data[0], txCanFrame.data[1], txCanFrame.data[2], txCanFrame.data[3],
458                         txCanFrame.data[4], txCanFrame.data[5], txCanFrame.data[6], txCanFrame.data[7]);
459
460                 if(!can_handler.simulation)
461                 {
462                         rc = (int)sendto(can_handler.socket, &txCanFrame, sizeof(struct can_frame), 0,
463                                 (struct sockaddr*)&can_handler.txAddress, sizeof(can_handler.txAddress));
464                         if (rc < 0)
465                         {
466                                 AFB_ERROR("Sending CAN frame failed.");
467                         }
468                 }
469         }
470         else
471         {
472                 AFB_ERROR("socket not initialized. Attempt to reopen can device socket.");
473                 open_can_dev();
474         }
475         return rc;
476 }
477
478 /*****************************************************************************************/
479 /*****************************************************************************************/
480 /**                                                                                     **/
481 /**                                                                                     **/
482 /**        SECTION: BINDING VERBS IMPLEMENTATION                                        **/
483 /**                                                                                     **/
484 /**                                                                                     **/
485 /*****************************************************************************************/
486 /*****************************************************************************************/
487
488 /*
489  * @brief Get fan speed HVAC system
490  *
491  * @param struct afb_req : an afb request structure
492  *
493  */
494 static void get_fanspeed(struct afb_req request)
495 {
496         json_object *ret_json;
497         uint8_t fanspeed = read_fanspeed();
498
499         ret_json = json_object_new_object();
500         json_object_object_add(ret_json, "FanSpeed", json_object_new_int(fanspeed));
501
502         afb_req_success(request, ret_json, NULL);
503 }
504
505 /*
506  * @brief Read Consign right zone temperature for HVAC system
507  *
508  * @param struct afb_req : an afb request structure
509  *
510  */
511 static void get_temp_right_zone(struct afb_req request)
512 {
513         json_object *ret_json;
514         uint8_t temp = read_temp_right_zone();
515
516         ret_json = json_object_new_object();
517         json_object_object_add(ret_json, "RightTemperature", json_object_new_int(temp));
518
519         afb_req_success(request, ret_json, NULL);
520 }
521
522 /*
523  * @brief Read Consign left zone temperature for HVAC system
524  *
525  * @param struct afb_req : an afb request structure
526  *
527  */
528 static void get_temp_left_zone(struct afb_req request)
529 {
530         json_object *ret_json;
531         uint8_t temp = read_temp_left_zone();
532
533         ret_json = json_object_new_object();
534         json_object_object_add(ret_json, "LeftTemperature", json_object_new_int(temp));
535
536         afb_req_success(request, ret_json, NULL);
537 }
538
539 /*
540  * @brief Read all values
541  *
542  * @param struct afb_req : an afb request structure
543  *
544  */
545 static void get(struct afb_req request)
546 {
547         AFB_DEBUG("Getting all values");
548         json_object *ret_json;
549
550         ret_json = json_object_new_object();
551         json_object_object_add(ret_json, "LeftTemperature", json_object_new_int(read_temp_left_zone()));
552         json_object_object_add(ret_json, "RightTemperature", json_object_new_int(read_temp_right_zone()));
553         json_object_object_add(ret_json, "FanSpeed", json_object_new_int(read_fanspeed()));
554
555         afb_req_success(request, ret_json, NULL);
556 }
557
558 /*
559  * @brief Set a component value using a json object retrieved from request
560  *
561  * @param struct afb_req : an afb request structure
562  *
563  */
564 static void set(struct afb_req request)
565 {
566         int i, rc, x, changed;
567         double d;
568         struct json_object *query, *val;
569         uint8_t values[sizeof hvac_values / sizeof *hvac_values];
570         uint8_t saves[sizeof hvac_values / sizeof *hvac_values];
571
572         /* records initial values */
573         AFB_DEBUG("Records initial values");
574         i = (int)(sizeof hvac_values / sizeof *hvac_values);
575         while (i) {
576                 i--;
577                 values[i] = saves[i] = hvac_values[i].value;
578         }
579
580         /* Loop getting arguments */
581         query = afb_req_json(request);
582         changed = 0;
583         i = (int)(sizeof hvac_values / sizeof *hvac_values);
584         AFB_DEBUG("Looping for args. i: %d", i);
585         while (i)
586         {
587                 i--;
588                 AFB_DEBUG("Searching... query: %s, i: %d, comp: %s", json_object_to_json_string(query), i, hvac_values[i].name);
589                 if (json_object_object_get_ex(query, hvac_values[i].name, &val))
590                 {
591                         AFB_DEBUG("We got it. Tests if it is an int or double.");
592                         if (json_object_is_type(val, json_type_int)) {
593                                 x = json_object_get_int(val);
594                                 AFB_DEBUG("We get an int: %d",x);
595                         }
596                         else if (json_object_is_type(val, json_type_double)) {
597                                 d = json_object_get_double(val);
598                                 x = (int)round(d);
599                                 AFB_DEBUG("We get a double: %f => %d",d,x);
600                         }
601                         else {
602                                 afb_req_fail_f(request, "bad-request",
603                                         "argument '%s' isn't integer or double", hvac_values[i].name);
604                                 return;
605                         }
606                         if (x < 0 || x > 255)
607                         {
608                                 afb_req_fail_f(request, "bad-request",
609                                         "argument '%s' is out of bounds", hvac_values[i].name);
610                                 return;
611                         }
612                         if (values[i] != x) {
613                                 values[i] = (uint8_t)x;
614                                 changed = 1;
615                                 AFB_DEBUG("%s changed to %d",hvac_values[i].name,x);
616                         }
617                 }
618                 else {
619                         AFB_DEBUG("%s not found in query!",hvac_values[i].name);
620                 }
621         }
622
623         /* attemps to set new values */
624         AFB_DEBUG("Diff: %d", changed);
625         if (changed)
626         {
627                 i = (int)(sizeof hvac_values / sizeof *hvac_values);
628                 while (i) {
629                         i--;
630                         hvac_values[i].value = values[i];
631                 }
632                 rc = write_can();
633                 if (rc >= 0)
634                         afb_req_success(request, NULL, NULL);
635                 else if (retry(write_can)) {
636                         /* restore initial values */
637                         i = (int)(sizeof hvac_values / sizeof *hvac_values);
638                         while (i) {
639                                 i--;
640                                 hvac_values[i].value = saves[i];
641                         }
642                         afb_req_fail(request, "error", "CAN error");
643                 }
644         }
645         else {
646                 afb_req_success(request, NULL, "No changes");
647         }
648 }
649
650 int bindingServicePreInit(struct afb_service service)
651 {
652         return open_can_dev();
653 }
654
655 int bindingServiceInit(struct afb_service service)
656 {
657         event = afb_daemon_make_event("language");
658         if(afb_daemon_require_api("identity", 1))
659                 return -1;
660         return afb_service_call_sync("identity", "subscribe", NULL, NULL);
661 }
662
663 void onEvent(const char *event_name, struct json_object *object)
664 {
665         json_object *args, *language = json_object_new_object();
666         json_object *id_evt_name, *current_identity;
667
668         AFB_NOTICE("Event '%s' received: %s", event_name,
669                 json_object_to_json_string_ext(object, JSON_C_TO_STRING_PRETTY));
670
671         if (json_object_object_get_ex(object, "eventName", &id_evt_name) &&
672           !strcmp(json_object_get_string(id_evt_name), "login") &&
673           !afb_service_call_sync("identity", "get", NULL, &current_identity)) {
674                 json_object *response;
675                 if (! json_object_object_get_ex(current_identity, "response", &response) || ! json_object_object_get_ex(response, "graphPreferredLanguage", &language)) {
676                         language = json_object_new_string("en_US");
677                 }
678                 afb_event_broadcast(event, language);
679         }
680 }
681
682 // TODO: Have to change session management flag to AFB_SESSION_CHECK to use token auth
683 static const struct afb_verb_v2 _afb_verbs_v2_hvac[]= {
684         {
685                 .verb = "get_temp_left_zone",
686                 .callback = get_temp_left_zone,
687                 .auth = NULL,
688                 .info = "Get the left zone temperature",
689                 .session = AFB_SESSION_NONE_V2
690         },
691         {
692                 .verb = "get_temp_right_zone",
693                 .callback = get_temp_right_zone,
694                 .auth = NULL,
695                 .info = "Get the right zone temperature",
696                 .session = AFB_SESSION_NONE_V2
697         },
698         {
699                 .verb = "get_fanspeed",
700                 .callback = get_fanspeed,
701                 .auth = NULL,
702                 .info = "Read fan speed",
703                 .session = AFB_SESSION_NONE_V2
704         },
705         {
706                 .verb = "get",
707                 .callback = get,
708                 .auth = NULL,
709                 .info = "Read all speed",
710                 .session = AFB_SESSION_NONE_V2
711         },
712         {
713                 .verb = "set",
714                 .callback = set,
715                 .auth = NULL,
716                 .info = "Set a HVAC component value",
717                 .session = AFB_SESSION_NONE_V2
718         },
719         {
720                 .verb = "temp_left_zone_led",
721                 .callback = temp_left_zone_led,
722                 .auth = NULL,
723                 .info = "Turn on LED on left temperature zone",
724                 .session = AFB_SESSION_NONE_V2
725         },
726         {
727                 .verb = "temp_right_zone_led",
728                 .callback = temp_right_zone_led,
729                 .auth = NULL,
730                 .info = "Turn on LED on left temperature zone",
731                 .session = AFB_SESSION_NONE_V2
732
733         },
734         {
735                 .verb = NULL,
736                 .callback = NULL,
737                 .auth = NULL,
738                 .info = NULL,
739                 .session = 0
740         }
741 };
742
743 const struct afb_binding_v2 afbBindingV2 = {
744     .api = "hvac",
745     .specification = NULL,
746     .info = "HVAC service",
747     .verbs = _afb_verbs_v2_hvac,
748     .preinit = bindingServicePreInit,
749     .init = bindingServiceInit,
750     .onevent = onEvent,
751     .noconcurrency = 0
752 };