Fix dbus parameter 'ay' to 'a(y)'
[platform/core/connectivity/zigbee-manager.git] / zigbee-daemon / zigbee-interface / src / zigbee_service_dbus_interface_mfglib_control.c
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Contact: Suresh Kumar N (suresh.n@samsung.com)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18
19 #include "zigbee_service_interface_common.h"
20
21 #include <zblib_driver_mfglib_control.h>
22
23 static void on_mfglib_control_start_resp(ZigBeeServiceInterface *service_interface,
24         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
25 {
26         ZigbeeServiceInterfaceRespCbData_t *cb_data =
27                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
28
29         NOT_USED(cb_data);
30         NOT_USED(service_interface);
31         NOT_USED(request_id);
32         NOT_USED(resp_data);
33         NOT_USED(resp_data_len);
34 }
35
36 static gboolean on_mfglib_control_start(ZigbeeMfglib_control *mfglib_control_object,
37         GDBusMethodInvocation *invocation,
38         GVariant *eui64,
39         gboolean mfglib_start,
40         gpointer user_data)
41 {
42         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
43         ZigbeeMfglibControlStart_t req;
44         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
45
46         GVariantIter *iter = NULL;
47         guint i = 0;
48
49         gboolean ret;
50
51         memset(&req, 0x0, sizeof(ZigbeeMfglibControlStart_t));
52
53         /* Update request structure */
54         g_variant_get(eui64, "a(y)", &iter);
55         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
56                 i++;
57                 if (i >= ZIGBEE_EUI64_SIZE)
58                         break;
59         }
60         req.mfglib_start = ((mfglib_start == TRUE) ? 1 : 0);
61
62         /* Allocate response callback data */
63         resp_cb_data =
64                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
65                         invocation, NULL, 0);
66         if (NULL == resp_cb_data) {
67                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
68
69                 /* Send failure response */
70                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
71
72                 return TRUE;
73         }
74
75         /* Dispatch request */
76         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
77                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
78                 ZBLIB_MFGLIB_CONTROL_OPS_START,
79                 &req, sizeof(req),
80                 on_mfglib_control_start_resp, resp_cb_data);
81         if (FALSE == ret) {
82                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
83
84                 /* Free response callback data */
85                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
86
87                 /* Send failure response */
88                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
89
90                 return TRUE;
91         }
92
93         return TRUE;
94 }
95
96 static void on_mfglib_control_end_resp(ZigBeeServiceInterface *service_interface,
97         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
98 {
99         ZigbeeServiceInterfaceRespCbData_t *cb_data =
100                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
101
102         NOT_USED(cb_data);
103         NOT_USED(service_interface);
104         NOT_USED(request_id);
105         NOT_USED(resp_data);
106         NOT_USED(resp_data_len);
107 }
108
109 static gboolean on_mfglib_control_end(ZigbeeMfglib_control *mfglib_control_object,
110         GDBusMethodInvocation *invocation,
111         GVariant *eui64,
112         gpointer user_data)
113 {
114         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
115         ZigbeeMfglibControlEnd_t req;
116         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
117
118         GVariantIter *iter = NULL;
119         guint i = 0;
120
121         gboolean ret;
122
123         memset(&req, 0x0, sizeof(ZigbeeMfglibControlEnd_t));
124
125         /* Update request structure */
126         g_variant_get(eui64, "a(y)", &iter);
127         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
128                 i++;
129                 if (i >= ZIGBEE_EUI64_SIZE)
130                         break;
131         }
132
133         /* Allocate response callback data */
134         resp_cb_data =
135                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
136                         invocation, NULL, 0);
137         if (NULL == resp_cb_data) {
138                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
139
140                 /* Send failure response */
141                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
142
143                 return TRUE;
144         }
145
146         /* Dispatch request */
147         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
148                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
149                 ZBLIB_MFGLIB_CONTROL_OPS_END,
150                 &req, sizeof(req),
151                 on_mfglib_control_end_resp, resp_cb_data);
152         if (FALSE == ret) {
153                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
154
155                 /* Free response callback data */
156                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
157
158                 /* Send failure response */
159                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
160
161                 return TRUE;
162         }
163
164         return TRUE;
165 }
166
167 static void on_mfglib_control_start_tone_resp(ZigBeeServiceInterface *service_interface,
168         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
169 {
170         ZigbeeServiceInterfaceRespCbData_t *cb_data =
171                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
172
173         NOT_USED(cb_data);
174         NOT_USED(service_interface);
175         NOT_USED(request_id);
176         NOT_USED(resp_data);
177         NOT_USED(resp_data_len);
178 }
179
180 static gboolean on_mfglib_control_start_tone(ZigbeeMfglib_control *mfglib_control_object,
181         GDBusMethodInvocation *invocation,
182         GVariant *eui64,
183         gpointer user_data)
184 {
185         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
186         ZigbeeMfglibControlStartTone_t req;
187         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
188
189         GVariantIter *iter = NULL;
190         guint i = 0;
191
192         gboolean ret;
193
194         memset(&req, 0x0, sizeof(ZigbeeMfglibControlStartTone_t));
195
196         /* Update request structure */
197         g_variant_get(eui64, "a(y)", &iter);
198         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
199                 i++;
200                 if (i >= ZIGBEE_EUI64_SIZE)
201                         break;
202         }
203
204         /* Allocate response callback data */
205         resp_cb_data =
206                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
207                         invocation, NULL, 0);
208         if (NULL == resp_cb_data) {
209                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
210
211                 /* Send failure response */
212                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
213
214                 return TRUE;
215         }
216
217         /* Dispatch request */
218         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
219                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
220                 ZBLIB_MFGLIB_CONTROL_OPS_START_TONE,
221                 &req, sizeof(req),
222                 on_mfglib_control_start_tone_resp, resp_cb_data);
223         if (FALSE == ret) {
224                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
225
226                 /* Free response callback data */
227                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
228
229                 /* Send failure response */
230                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
231
232                 return TRUE;
233         }
234
235         return TRUE;
236 }
237
238 static void on_mfglib_control_stop_tone_resp(ZigBeeServiceInterface *service_interface,
239         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
240 {
241         ZigbeeServiceInterfaceRespCbData_t *cb_data =
242                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
243
244         NOT_USED(cb_data);
245         NOT_USED(service_interface);
246         NOT_USED(request_id);
247         NOT_USED(resp_data);
248         NOT_USED(resp_data_len);
249 }
250
251 static gboolean on_mfglib_control_stop_tone(ZigbeeMfglib_control *mfglib_control_object,
252         GDBusMethodInvocation *invocation,
253         GVariant *eui64,
254         gpointer user_data)
255 {
256         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
257         ZigbeeMfglibControlStopTone_t req;
258         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
259
260         GVariantIter *iter = NULL;
261         guint i = 0;
262
263         gboolean ret;
264
265         memset(&req, 0x0, sizeof(ZigbeeMfglibControlStopTone_t));
266
267         /* Update request structure */
268         g_variant_get(eui64, "a(y)", &iter);
269         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
270                 i++;
271                 if (i >= ZIGBEE_EUI64_SIZE)
272                         break;
273         }
274
275         /* Allocate response callback data */
276         resp_cb_data =
277                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
278                         invocation, NULL, 0);
279         if (NULL == resp_cb_data) {
280                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
281
282                 /* Send failure response */
283                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
284
285                 return TRUE;
286         }
287
288         /* Dispatch request */
289         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
290                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
291                 ZBLIB_MFGLIB_CONTROL_OPS_STOP_TONE,
292                 &req, sizeof(req),
293                 on_mfglib_control_stop_tone_resp, resp_cb_data);
294         if (FALSE == ret) {
295                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
296
297                 /* Free response callback data */
298                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
299
300                 /* Send failure response */
301                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
302
303                 return TRUE;
304         }
305
306         return TRUE;
307 }
308
309 static void on_mfglib_control_start_stream_resp(ZigBeeServiceInterface *service_interface,
310         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
311 {
312         ZigbeeServiceInterfaceRespCbData_t *cb_data =
313                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
314
315         NOT_USED(cb_data);
316         NOT_USED(service_interface);
317         NOT_USED(request_id);
318         NOT_USED(resp_data);
319         NOT_USED(resp_data_len);
320 }
321
322 static gboolean on_mfglib_control_start_stream(ZigbeeMfglib_control *mfglib_control_object,
323         GDBusMethodInvocation *invocation,
324         GVariant *eui64,
325         gpointer user_data)
326 {
327         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
328         ZigbeeMfglibControlStartStream_t req;
329         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
330
331         GVariantIter *iter = NULL;
332         guint i = 0;
333
334         gboolean ret;
335
336         memset(&req, 0x0, sizeof(ZigbeeMfglibControlStartStream_t));
337
338         /* Update request structure */
339         g_variant_get(eui64, "a(y)", &iter);
340         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
341                 i++;
342                 if (i >= ZIGBEE_EUI64_SIZE)
343                         break;
344         }
345
346         /* Allocate response callback data */
347         resp_cb_data =
348                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
349                         invocation, NULL, 0);
350         if (NULL == resp_cb_data) {
351                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
352
353                 /* Send failure response */
354                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
355
356                 return TRUE;
357         }
358
359         /* Dispatch request */
360         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
361                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
362                 ZBLIB_MFGLIB_CONTROL_OPS_START_STREAM,
363                 &req, sizeof(req),
364                 on_mfglib_control_start_stream_resp, resp_cb_data);
365         if (FALSE == ret) {
366                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
367
368                 /* Free response callback data */
369                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
370
371                 /* Send failure response */
372                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
373
374                 return TRUE;
375         }
376
377         return TRUE;
378 }
379
380 static void on_mfglib_control_stop_stream_resp(ZigBeeServiceInterface *service_interface,
381         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
382 {
383         ZigbeeServiceInterfaceRespCbData_t *cb_data =
384                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
385
386         NOT_USED(cb_data);
387         NOT_USED(service_interface);
388         NOT_USED(request_id);
389         NOT_USED(resp_data);
390         NOT_USED(resp_data_len);
391 }
392
393 static gboolean on_mfglib_control_stop_stream(ZigbeeMfglib_control *mfglib_control_object,
394         GDBusMethodInvocation *invocation,
395         GVariant *eui64,
396         gpointer user_data)
397 {
398         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
399         ZigbeeMfglibControlStopStream_t req;
400         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
401
402         GVariantIter *iter = NULL;
403         guint i = 0;
404
405         gboolean ret;
406
407         memset(&req, 0x0, sizeof(ZigbeeMfglibControlStopStream_t));
408
409         /* Update request structure */
410         g_variant_get(eui64, "a(y)", &iter);
411         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
412                 i++;
413                 if (i >= ZIGBEE_EUI64_SIZE)
414                         break;
415         }
416
417         /* Allocate response callback data */
418         resp_cb_data =
419                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
420                         invocation, NULL, 0);
421         if (NULL == resp_cb_data) {
422                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
423
424                 /* Send failure response */
425                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
426
427                 return TRUE;
428         }
429
430         /* Dispatch request */
431         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
432                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
433                 ZBLIB_MFGLIB_CONTROL_OPS_STOP_STREAM,
434                 &req, sizeof(req),
435                 on_mfglib_control_stop_stream_resp, resp_cb_data);
436         if (FALSE == ret) {
437                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
438
439                 /* Free response callback data */
440                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
441
442                 /* Send failure response */
443                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
444
445                 return TRUE;
446         }
447
448         return TRUE;
449 }
450
451 static void on_mfglib_control_send_packet_resp(ZigBeeServiceInterface *service_interface,
452         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
453 {
454         ZigbeeServiceInterfaceRespCbData_t *cb_data =
455                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
456
457         NOT_USED(cb_data);
458         NOT_USED(service_interface);
459         NOT_USED(request_id);
460         NOT_USED(resp_data);
461         NOT_USED(resp_data_len);
462 }
463
464 static gboolean on_mfglib_control_send_packet(ZigbeeMfglib_control *mfglib_control_object,
465         GDBusMethodInvocation *invocation,
466         GVariant *packet_content,
467         gint packet_length,
468         gpointer user_data)
469 {
470         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
471         ZigbeeMfglibControlSendPacket_t req;
472         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
473
474         GVariantIter *iter = NULL;
475         guint i = 0;
476
477         gboolean ret;
478
479         memset(&req, 0x0, sizeof(ZigbeeMfglibControlSendPacket_t));
480
481         /* Update request structure */
482         g_variant_get(packet_content, "a(y)", &iter);
483         while (g_variant_iter_loop(iter, "(y)", &(req.packet_content[i]))) {
484                 i++;
485                 if (i >= (guint)packet_length)
486                         break;
487         }
488         req.packet_length = packet_length;
489
490         /* Allocate response callback data */
491         resp_cb_data =
492                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
493                         invocation, NULL, 0);
494         if (NULL == resp_cb_data) {
495                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
496
497                 /* Send failure response */
498                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
499
500                 return TRUE;
501         }
502
503         /* Dispatch request */
504         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
505                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
506                 ZBLIB_MFGLIB_CONTROL_OPS_SEND_PACKET,
507                 &req, sizeof(req),
508                 on_mfglib_control_send_packet_resp, resp_cb_data);
509         if (FALSE == ret) {
510                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
511
512                 /* Free response callback data */
513                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
514
515                 /* Send failure response */
516                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
517
518                 return TRUE;
519         }
520
521         return TRUE;
522 }
523
524 static void on_mfglib_control_set_channel_resp(ZigBeeServiceInterface *service_interface,
525         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
526 {
527         ZigbeeServiceInterfaceRespCbData_t *cb_data =
528                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
529
530         NOT_USED(cb_data);
531         NOT_USED(service_interface);
532         NOT_USED(request_id);
533         NOT_USED(resp_data);
534         NOT_USED(resp_data_len);
535 }
536
537 static gboolean on_mfglib_control_set_channel(ZigbeeMfglib_control *mfglib_control_object,
538         GDBusMethodInvocation *invocation,
539         GVariant *eui64,
540         gchar channel,
541         gpointer user_data)
542 {
543         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
544         ZigbeeMfglibControlSetChannel_t req;
545         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
546
547         GVariantIter *iter = NULL;
548         guint i = 0;
549
550         gboolean ret;
551
552         memset(&req, 0x0, sizeof(ZigbeeMfglibControlSetChannel_t));
553
554         /* Update request structure */
555         g_variant_get(eui64, "a(y)", &iter);
556         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
557                 i++;
558                 if (i >= ZIGBEE_EUI64_SIZE)
559                         break;
560         }
561         req.channel = channel;
562
563         /* Allocate response callback data */
564         resp_cb_data =
565                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
566                         invocation, NULL, 0);
567         if (NULL == resp_cb_data) {
568                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
569
570                 /* Send failure response */
571                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
572
573                 return TRUE;
574         }
575
576         /* Dispatch request */
577         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
578                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
579                 ZBLIB_MFGLIB_CONTROL_OPS_SET_CHANNEL,
580                 &req, sizeof(req),
581                 on_mfglib_control_set_channel_resp, resp_cb_data);
582         if (FALSE == ret) {
583                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
584
585                 /* Free response callback data */
586                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
587
588                 /* Send failure response */
589                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
590
591                 return TRUE;
592         }
593
594         return TRUE;
595 }
596
597 static void on_mfglib_control_get_channel_resp(ZigBeeServiceInterface *service_interface,
598         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
599 {
600         ZigbeeServiceInterfaceRespCbData_t *cb_data =
601                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
602
603         NOT_USED(cb_data);
604         NOT_USED(service_interface);
605         NOT_USED(request_id);
606         NOT_USED(resp_data);
607         NOT_USED(resp_data_len);
608 }
609
610 static gboolean on_mfglib_control_get_channel(ZigbeeMfglib_control *mfglib_control_object,
611         GDBusMethodInvocation *invocation,
612         GVariant *eui64,
613         gpointer user_data)
614 {
615         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
616         ZigbeeMfglibControlGetChannel_t req;
617         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
618
619         GVariantIter *iter = NULL;
620         guint i = 0;
621
622         gboolean ret;
623
624         memset(&req, 0x0, sizeof(ZigbeeMfglibControlGetChannel_t));
625
626         /* Update request structure */
627         g_variant_get(eui64, "a(y)", &iter);
628         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
629                 i++;
630                 if (i >= ZIGBEE_EUI64_SIZE)
631                         break;
632         }
633
634         /* Allocate response callback data */
635         resp_cb_data =
636                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
637                         invocation, NULL, 0);
638         if (NULL == resp_cb_data) {
639                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
640
641                 /* Send failure response */
642                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
643
644                 return TRUE;
645         }
646
647         /* Dispatch request */
648         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
649                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
650                 ZBLIB_MFGLIB_CONTROL_OPS_GET_CHANNEL,
651                 &req, sizeof(req),
652                 on_mfglib_control_get_channel_resp, resp_cb_data);
653         if (FALSE == ret) {
654                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
655
656                 /* Free response callback data */
657                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
658
659                 /* Send failure response */
660                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
661
662                 return TRUE;
663         }
664
665         return TRUE;
666 }
667
668 static void on_mfglib_control_set_power_resp(ZigBeeServiceInterface *service_interface,
669         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
670 {
671         ZigbeeServiceInterfaceRespCbData_t *cb_data =
672                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
673
674         NOT_USED(cb_data);
675         NOT_USED(service_interface);
676         NOT_USED(request_id);
677         NOT_USED(resp_data);
678         NOT_USED(resp_data_len);
679 }
680
681 static gboolean on_mfglib_control_set_power(ZigbeeMfglib_control *mfglib_control_object,
682         GDBusMethodInvocation *invocation,
683         GVariant *eui64,
684         gshort tx_power_mode,
685         guint power,
686         gpointer user_data)
687 {
688         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
689         ZigbeeMfglibControlSetPower_t req;
690         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
691
692         GVariantIter *iter = NULL;
693         guint i = 0;
694
695         gboolean ret;
696
697         memset(&req, 0x0, sizeof(ZigbeeMfglibControlSetPower_t));
698
699         /* Update request structure */
700         g_variant_get(eui64, "a(y)", &iter);
701         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
702                 i++;
703                 if (i >= ZIGBEE_EUI64_SIZE)
704                         break;
705         }
706         req.tx_power_mode = tx_power_mode;
707         req.power = power;
708
709         /* Allocate response callback data */
710         resp_cb_data =
711                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
712                         invocation, NULL, 0);
713         if (NULL == resp_cb_data) {
714                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
715
716                 /* Send failure response */
717                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
718
719                 return TRUE;
720         }
721
722         /* Dispatch request */
723         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
724                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
725                 ZBLIB_MFGLIB_CONTROL_OPS_SET_POWER,
726                 &req, sizeof(req),
727                 on_mfglib_control_set_power_resp, resp_cb_data);
728         if (FALSE == ret) {
729                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
730
731                 /* Free response callback data */
732                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
733
734                 /* Send failure response */
735                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
736
737                 return TRUE;
738         }
739
740         return TRUE;
741 }
742
743 static void on_mfglib_control_get_power_resp(ZigBeeServiceInterface *service_interface,
744         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
745 {
746         ZigbeeServiceInterfaceRespCbData_t *cb_data =
747                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
748
749         NOT_USED(cb_data);
750         NOT_USED(service_interface);
751         NOT_USED(request_id);
752         NOT_USED(resp_data);
753         NOT_USED(resp_data_len);
754 }
755
756 static gboolean on_mfglib_control_get_power(ZigbeeMfglib_control *mfglib_control_object,
757         GDBusMethodInvocation *invocation,
758         GVariant *eui64,
759         gpointer user_data)
760 {
761         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
762         ZigbeeMfglibControlGetPower_t req;
763         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
764
765         GVariantIter *iter = NULL;
766         guint i = 0;
767
768         gboolean ret;
769
770         memset(&req, 0x0, sizeof(ZigbeeMfglibControlGetPower_t));
771
772         /* Update request structure */
773         g_variant_get(eui64, "a(y)", &iter);
774         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
775                 i++;
776                 if (i >= ZIGBEE_EUI64_SIZE)
777                         break;
778         }
779
780         /* Allocate response callback data */
781         resp_cb_data =
782                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
783                         invocation, NULL, 0);
784         if (NULL == resp_cb_data) {
785                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
786
787                 /* Send failure response */
788                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
789
790                 return TRUE;
791         }
792
793         /* Dispatch request */
794         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
795                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
796                 ZBLIB_MFGLIB_CONTROL_OPS_GET_POWER,
797                 &req, sizeof(req),
798                 on_mfglib_control_get_power_resp, resp_cb_data);
799         if (FALSE == ret) {
800                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
801
802                 /* Free response callback data */
803                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
804
805                 /* Send failure response */
806                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
807
808                 return TRUE;
809         }
810
811         return TRUE;
812 }
813
814 static void on_mfglib_control_set_synoffset_resp(ZigBeeServiceInterface *service_interface,
815         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
816 {
817         ZigbeeServiceInterfaceRespCbData_t *cb_data =
818                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
819
820         NOT_USED(cb_data);
821         NOT_USED(service_interface);
822         NOT_USED(request_id);
823         NOT_USED(resp_data);
824         NOT_USED(resp_data_len);
825 }
826
827 static gboolean on_mfglib_control_set_synoffset(ZigbeeMfglib_control *mfglib_control_object,
828         GDBusMethodInvocation *invocation,
829         GVariant *eui64,
830         gchar test_channel,
831         gpointer user_data)
832 {
833         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
834         ZigbeeMfglibControlSetSynOffset_t req;
835         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
836
837         GVariantIter *iter = NULL;
838         guint i = 0;
839
840         gboolean ret;
841
842         memset(&req, 0x0, sizeof(ZigbeeMfglibControlSetSynOffset_t));
843
844         /* Update request structure */
845         g_variant_get(eui64, "a(y)", &iter);
846         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
847                 i++;
848                 if (i >= ZIGBEE_EUI64_SIZE)
849                         break;
850         }
851         req.channel = test_channel;
852
853         /* Allocate response callback data */
854         resp_cb_data =
855                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
856                         invocation, NULL, 0);
857         if (NULL == resp_cb_data) {
858                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
859
860                 /* Send failure response */
861                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
862
863                 return TRUE;
864         }
865
866         /* Dispatch request */
867         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
868                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
869                 ZBLIB_MFGLIB_CONTROL_OPS_SET_SYNOFFSET,
870                 &req, sizeof(req),
871                 on_mfglib_control_set_synoffset_resp, resp_cb_data);
872         if (FALSE == ret) {
873                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
874
875                 /* Free response callback data */
876                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
877
878                 /* Send failure response */
879                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
880
881                 return TRUE;
882         }
883
884         return TRUE;
885 }
886
887 static void on_mfglib_control_get_synoffset_resp(ZigBeeServiceInterface *service_interface,
888         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
889 {
890         ZigbeeServiceInterfaceRespCbData_t *cb_data =
891                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
892
893         NOT_USED(cb_data);
894         NOT_USED(service_interface);
895         NOT_USED(request_id);
896         NOT_USED(resp_data);
897         NOT_USED(resp_data_len);
898 }
899
900 static gboolean on_mfglib_control_get_synoffset(ZigbeeMfglib_control *mfglib_control_object,
901         GDBusMethodInvocation *invocation,
902         GVariant *packet,
903         gint packet_length,
904         gchar link_quality,
905         gchar rssi,
906         gpointer user_data)
907 {
908         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
909         ZigbeeMfglibControlGetSynOffset_t req;
910         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
911
912         GVariantIter *iter = NULL;
913         guint i = 0;
914
915         gboolean ret;
916
917         memset(&req, 0x0, sizeof(ZigbeeMfglibControlGetSynOffset_t));
918
919         /* Update request structure */
920         g_variant_get(packet, "a(y)", &iter);
921         while (g_variant_iter_loop(iter, "(y)", &(req.packet[i]))) {
922                 i++;
923                 if (i >= (guint)packet_length)
924                         break;
925         }
926         req.packet_length = packet_length;
927         req.link_quality = link_quality;
928         req.rssi = rssi;
929
930         /* Allocate response callback data */
931         resp_cb_data =
932                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
933                         invocation, NULL, 0);
934         if (NULL == resp_cb_data) {
935                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
936
937                 /* Send failure response */
938                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
939
940                 return TRUE;
941         }
942
943         /* Dispatch request */
944         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
945                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
946                 ZBLIB_MFGLIB_CONTROL_OPS_GET_SYNOFFSET,
947                 &req, sizeof(req),
948                 on_mfglib_control_get_synoffset_resp, resp_cb_data);
949         if (FALSE == ret) {
950                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
951
952                 /* Free response callback data */
953                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
954
955                 /* Send failure response */
956                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
957
958                 return TRUE;
959         }
960
961         return TRUE;
962 }
963
964 static void on_mfglib_control_rx_start_resp(ZigBeeServiceInterface *service_interface,
965         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
966 {
967         ZigbeeServiceInterfaceRespCbData_t *cb_data =
968                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
969
970         NOT_USED(cb_data);
971         NOT_USED(service_interface);
972         NOT_USED(request_id);
973         NOT_USED(resp_data);
974         NOT_USED(resp_data_len);
975 }
976
977 static gboolean on_mfglib_control_rx_start(ZigbeeMfglib_control *mfglib_control_object,
978         GDBusMethodInvocation *invocation,
979         GVariant *eui64,
980         gpointer user_data)
981 {
982         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
983         ZigbeeMfglibControlRxStart_t req;
984         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
985
986         GVariantIter *iter = NULL;
987         guint i = 0;
988
989         gboolean ret;
990
991         memset(&req, 0x0, sizeof(ZigbeeMfglibControlRxStart_t));
992
993         /* Update request structure */
994         g_variant_get(eui64, "a(y)", &iter);
995         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
996                 i++;
997                 if (i >= ZIGBEE_EUI64_SIZE)
998                         break;
999         }
1000
1001         /* Allocate response callback data */
1002         resp_cb_data =
1003                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
1004                         invocation, NULL, 0);
1005         if (NULL == resp_cb_data) {
1006                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1007
1008                 /* Send failure response */
1009                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1010
1011                 return TRUE;
1012         }
1013
1014         /* Dispatch request */
1015         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1016                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
1017                 ZBLIB_MFGLIB_CONTROL_OPS_RX_START,
1018                 &req, sizeof(req),
1019                 on_mfglib_control_rx_start_resp, resp_cb_data);
1020         if (FALSE == ret) {
1021                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1022
1023                 /* Free response callback data */
1024                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1025
1026                 /* Send failure response */
1027                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1028
1029                 return TRUE;
1030         }
1031
1032         return TRUE;
1033 }
1034
1035 static void on_mfglib_control_rx_stop_resp(ZigBeeServiceInterface *service_interface,
1036         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1037 {
1038         ZigbeeServiceInterfaceRespCbData_t *cb_data =
1039                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1040
1041         NOT_USED(cb_data);
1042         NOT_USED(service_interface);
1043         NOT_USED(request_id);
1044         NOT_USED(resp_data);
1045         NOT_USED(resp_data_len);
1046 }
1047
1048 static gboolean on_mfglib_control_rx_stop(ZigbeeMfglib_control *mfglib_control_object,
1049         GDBusMethodInvocation *invocation,
1050         GVariant *eui64,
1051         gpointer user_data)
1052 {
1053         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1054         ZigbeeMfglibControlRxStop_t req;
1055         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1056
1057         GVariantIter *iter = NULL;
1058         guint i = 0;
1059
1060         gboolean ret;
1061
1062         memset(&req, 0x0, sizeof(ZigbeeMfglibControlRxStop_t));
1063
1064         /* Update request structure */
1065         g_variant_get(eui64, "a(y)", &iter);
1066         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
1067                 i++;
1068                 if (i >= ZIGBEE_EUI64_SIZE)
1069                         break;
1070         }
1071
1072         /* Allocate response callback data */
1073         resp_cb_data =
1074                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
1075                         invocation, NULL, 0);
1076         if (NULL == resp_cb_data) {
1077                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1078
1079                 /* Send failure response */
1080                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1081
1082                 return TRUE;
1083         }
1084
1085         /* Dispatch request */
1086         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1087                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
1088                 ZBLIB_MFGLIB_CONTROL_OPS_RX_STOP,
1089                 &req, sizeof(req),
1090                 on_mfglib_control_rx_stop_resp, resp_cb_data);
1091         if (FALSE == ret) {
1092                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1093
1094                 /* Free response callback data */
1095                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1096
1097                 /* Send failure response */
1098                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1099
1100                 return TRUE;
1101         }
1102
1103         return TRUE;
1104 }
1105
1106 static void on_mfglib_control_rx_verify_resp(ZigBeeServiceInterface *service_interface,
1107         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1108 {
1109         ZigbeeServiceInterfaceRespCbData_t *cb_data =
1110                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1111
1112         NOT_USED(cb_data);
1113         NOT_USED(service_interface);
1114         NOT_USED(request_id);
1115         NOT_USED(resp_data);
1116         NOT_USED(resp_data_len);
1117 }
1118
1119 static gboolean on_mfglib_control_rx_verify(ZigbeeMfglib_control *mfglib_control_object,
1120         GDBusMethodInvocation *invocation,
1121         GVariant *eui64,
1122         gpointer user_data)
1123 {
1124         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1125         ZigbeeMfglibControlRxVerify_t req;
1126         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1127
1128         GVariantIter *iter = NULL;
1129         guint i = 0;
1130
1131         gboolean ret;
1132
1133         memset(&req, 0x0, sizeof(ZigbeeMfglibControlRxVerify_t));
1134
1135         /* Update request structure */
1136         g_variant_get(eui64, "a(y)", &iter);
1137         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
1138                 i++;
1139                 if (i >= ZIGBEE_EUI64_SIZE)
1140                         break;
1141         }
1142
1143         /* Allocate response callback data */
1144         resp_cb_data =
1145                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
1146                         invocation, NULL, 0);
1147         if (NULL == resp_cb_data) {
1148                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1149
1150                 /* Send failure response */
1151                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1152
1153                 return TRUE;
1154         }
1155
1156         /* Dispatch request */
1157         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1158                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
1159                 ZBLIB_MFGLIB_CONTROL_OPS_RX_VERIFY,
1160                 &req, sizeof(req),
1161                 on_mfglib_control_rx_verify_resp, resp_cb_data);
1162         if (FALSE == ret) {
1163                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1164
1165                 /* Free response callback data */
1166                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1167
1168                 /* Send failure response */
1169                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1170
1171                 return TRUE;
1172         }
1173
1174         return TRUE;
1175 }
1176
1177 static void on_mfglib_control_get_rssi_resp(ZigBeeServiceInterface *service_interface,
1178         guint request_id, gpointer resp_data, guint resp_data_len, gpointer resp_cb_data)
1179 {
1180         ZigbeeServiceInterfaceRespCbData_t *cb_data =
1181                 (ZigbeeServiceInterfaceRespCbData_t *)resp_cb_data;
1182
1183         NOT_USED(cb_data);
1184         NOT_USED(service_interface);
1185         NOT_USED(request_id);
1186         NOT_USED(resp_data);
1187         NOT_USED(resp_data_len);
1188 }
1189
1190 static gboolean on_mfglib_control_get_rssi(ZigbeeMfglib_control *mfglib_control_object,
1191         GDBusMethodInvocation *invocation,
1192         GVariant *eui64,
1193         gpointer user_data)
1194 {
1195         ZigBeeServiceInterface *service_interface = (ZigBeeServiceInterface *)user_data;
1196         ZigbeeMfglibControlGetRssi_t req;
1197         ZigbeeServiceInterfaceRespCbData_t *resp_cb_data = NULL;
1198
1199         GVariantIter *iter = NULL;
1200         guint i = 0;
1201
1202         gboolean ret;
1203
1204         memset(&req, 0x0, sizeof(ZigbeeMfglibControlGetRssi_t));
1205
1206         /* Update request structure */
1207         g_variant_get(eui64, "a(y)", &iter);
1208         while (g_variant_iter_loop(iter, "(y)", &(req.eui64[i]))) {
1209                 i++;
1210                 if (i >= ZIGBEE_EUI64_SIZE)
1211                         break;
1212         }
1213
1214         /* Allocate response callback data */
1215         resp_cb_data =
1216                 zigbee_service_dbus_interface_create_resp_cb_data(mfglib_control_object,
1217                         invocation, NULL, 0);
1218         if (NULL == resp_cb_data) {
1219                 Z_LOGE("zigbee_service_dbus_interface_create_resp_cb_data failed!");
1220
1221                 /* Send failure response */
1222                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1223
1224                 return TRUE;
1225         }
1226
1227         /* Dispatch request */
1228         ret = zigbee_service_dbus_interface_dispatch_request(service_interface,
1229                 ZBLIB_DRIVER_TYPE_MFGLIB_CONTROL,
1230                 ZBLIB_MFGLIB_CONTROL_OPS_GET_RSSI,
1231                 &req, sizeof(req),
1232                 on_mfglib_control_get_rssi_resp, resp_cb_data);
1233         if (FALSE == ret) {
1234                 Z_LOGE("zigbee_service_dbus_interface_dispatch_request failed!");
1235
1236                 /* Free response callback data */
1237                 zigbee_service_dbus_interface_destroy_resp_cb_data(resp_cb_data);
1238
1239                 /* Send failure response */
1240                 ZIGBEE_DBUS_FAIL_RESPONSE(invocation, ZIGBEE_DBUS_DEFAULT_REQ_FAILED_MSG);
1241
1242                 return TRUE;
1243         }
1244
1245         return TRUE;
1246 }
1247
1248 void zigbee_service_dbus_interface_mfglib_control_notification(ZigBeeServiceInterface *service_interface,
1249         guint noti_id, gpointer noti_data, guint noti_data_len, gpointer noti_cb_data)
1250 {
1251         if (NULL == service_interface) {
1252                 Z_LOGE("service_interface is NULL");
1253                 return;
1254         }
1255
1256         NOT_USED(noti_id);
1257         NOT_USED(noti_data);
1258         NOT_USED(noti_data_len);
1259         NOT_USED(noti_cb_data);
1260 }
1261
1262 gboolean zigbee_service_dbus_interface_mfglib_control_init(ZigBeeServiceInterface *service_interface,
1263         ZigbeeObjectSkeleton *zigbee_object)
1264 {
1265         ZigbeeMfglib_control *mfglib_control_object;
1266
1267         if (NULL == service_interface) {
1268                 Z_LOGE("service_interface is NULL");
1269                 return FALSE;
1270         }
1271
1272         mfglib_control_object = zigbee_mfglib_control_skeleton_new();
1273         zigbee_object_skeleton_set_mfglib_control(zigbee_object, mfglib_control_object);
1274         g_object_unref(mfglib_control_object);
1275
1276         Z_LOGI("mfglib_control_object: [%p]", mfglib_control_object);
1277
1278         /*
1279          * Register signal handlers for 'mfglib_control' interface
1280          */
1281         g_signal_connect(mfglib_control_object,
1282                 "handle-start",
1283                 G_CALLBACK(on_mfglib_control_start), service_interface);
1284
1285         g_signal_connect(mfglib_control_object,
1286                 "handle-end",
1287                 G_CALLBACK(on_mfglib_control_end), service_interface);
1288
1289         g_signal_connect(mfglib_control_object,
1290                 "handle-start-tone",
1291                 G_CALLBACK(on_mfglib_control_start_tone), service_interface);
1292
1293         g_signal_connect(mfglib_control_object,
1294                 "handle-stop-tone",
1295                 G_CALLBACK(on_mfglib_control_stop_tone), service_interface);
1296
1297         g_signal_connect(mfglib_control_object,
1298                 "handle-start-stream",
1299                 G_CALLBACK(on_mfglib_control_start_stream), service_interface);
1300
1301         g_signal_connect(mfglib_control_object,
1302                 "handle-stop-stream",
1303                 G_CALLBACK(on_mfglib_control_stop_stream), service_interface);
1304
1305         g_signal_connect(mfglib_control_object,
1306                 "handle-send-packet",
1307                 G_CALLBACK(on_mfglib_control_send_packet), service_interface);
1308
1309         g_signal_connect(mfglib_control_object,
1310                 "handle-set-channel",
1311                 G_CALLBACK(on_mfglib_control_set_channel), service_interface);
1312
1313         g_signal_connect(mfglib_control_object,
1314                 "handle-get-channel",
1315                 G_CALLBACK(on_mfglib_control_get_channel), service_interface);
1316
1317         g_signal_connect(mfglib_control_object,
1318                 "handle-set-power",
1319                 G_CALLBACK(on_mfglib_control_set_power), service_interface);
1320
1321         g_signal_connect(mfglib_control_object,
1322                 "handle-get-power",
1323                 G_CALLBACK(on_mfglib_control_get_power), service_interface);
1324
1325         g_signal_connect(mfglib_control_object,
1326                 "handle-set-synoffset",
1327                 G_CALLBACK(on_mfglib_control_set_synoffset), service_interface);
1328
1329         g_signal_connect(mfglib_control_object,
1330                 "handle-get-synoffset",
1331                 G_CALLBACK(on_mfglib_control_get_synoffset), service_interface);
1332
1333         g_signal_connect(mfglib_control_object,
1334                 "handle-rx-start",
1335                 G_CALLBACK(on_mfglib_control_rx_start), service_interface);
1336
1337         g_signal_connect(mfglib_control_object,
1338                 "handle-rx-stop",
1339                 G_CALLBACK(on_mfglib_control_rx_stop), service_interface);
1340
1341         g_signal_connect(mfglib_control_object,
1342                 "handle-rx-verify",
1343                 G_CALLBACK(on_mfglib_control_rx_verify), service_interface);
1344
1345         g_signal_connect(mfglib_control_object,
1346                 "handle-get-rssi",
1347                 G_CALLBACK(on_mfglib_control_get_rssi), service_interface);
1348
1349         return TRUE;
1350 }