4 * Copyright(C) 2007,2008 Ixonos Plc
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Boston, MA 02111.
38 AtCommandHandlerStatus
gsmd_device_handler_query_date_time (ModemInterface
*modem
,
42 AtCommandHandlerStatus
gsmd_device_handler_set_date_time (ModemInterface
*modem
,
46 AtCommandHandlerStatus
gsmd_device_handler_query_imei (ModemInterface
*modem
,
50 AtCommandHandlerStatus
gsmd_device_handler_query_revision (ModemInterface
*modem
,
54 AtCommandHandlerStatus
gsmd_device_handler_query_model (ModemInterface
*modem
,
58 AtCommandHandlerStatus
gsmd_device_handler_query_manufacturer (ModemInterface
*modem
,
62 AtCommandHandlerStatus
gsmd_device_handler_get_antenna_power (ModemInterface
*modem
,
66 AtCommandHandlerStatus
gsmd_device_handler_get_info (ModemInterface
*modem
,
70 static const AtCommand
74 { DATE_TIME_QUERY
, "AT+CCLK?\r\n", 100,
76 gsmd_device_handler_query_date_time
, NULL
, SIM_READY
, NULL
},
79 { SET_DATE_TIME
, "AT+CCLK=\"%s\"\r\n", 100000,
81 gsmd_device_handler_set_date_time
, NULL
, SIM_READY
, NULL
},
84 { IMEI_QUERY
, "AT+CGSN\r\n", 100,
86 gsmd_device_handler_query_imei
, NULL
, SIM_UNKNOWN
, NULL
},
89 { SW_REVISION_QUERY
, "AT+CGMR\r\n", 100,
91 gsmd_device_handler_query_revision
, NULL
, SIM_UNKNOWN
, NULL
},
94 { MODEL_QUERY
, "AT+CGMM\r\n", 100,
96 gsmd_device_handler_query_model
, NULL
, SIM_UNKNOWN
, NULL
},
99 { MANUFACTURER_QUERY
, "AT+CGMI\r\n", 100,
101 gsmd_device_handler_query_manufacturer
, NULL
, SIM_UNKNOWN
, NULL
},
104 { ANTENNA_POWER_GET
, "AT+CFUN?\r\n", 100,
106 gsmd_device_handler_get_antenna_power
, NULL
, SIM_UNKNOWN
, NULL
},
108 /* //Get capabilities */
109 /* { CAPABILITIES_GET, "AT+GCAP\r\n", 100, */
111 /* gsmd_device_handler_get_features, NULL, SIM_UNKNOWN}, */
113 { 0, NULL
, 100, TRUE
, 1,
114 NULL
, NULL
, SIM_UNKNOWN
},
116 }, *device_command_p
= device_commands
;
118 static const SymbolTable
120 { "CCLK", SYMBOL_CCLK
, },
121 { "CFUN", SYMBOL_CFUN
, },
122 { "CGSN", SYMBOL_CGSN
, },
123 { "CGMR", SYMBOL_CGMR
, },
124 { "CGMM", SYMBOL_CGMM
, },
125 { "CGMI", SYMBOL_CGMI
, },
127 }, *device_symbol_p
= device_symbols
;
130 void gsmd_device_init_at_handler(ModemInterface
* modem
)
132 while (device_symbol_p
->symbol_name
) {
133 g_scanner_add_symbol (modem
->scanner
, device_symbol_p
->symbol_name
,
134 GINT_TO_POINTER(device_symbol_p
->symbol_token
));
137 while (device_command_p
->command
) {
138 gsmd_modem_register_command (modem
,device_command_p
);
144 * @brief AtCommand to query datetime
146 * @param modem modem whose response to handle
148 static void gsmd_device_command_query_date_time (DeviceInterface
*device
,
151 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
152 gsmd_modem_post_at_command_id( modem
,
163 * @brief AtCommand to set datetime
165 * @param modem modem whose response to handle
166 * @param date_time datetime to set. Format "yy/MM/dd,hh:mm:ss±zz"
168 static void gsmd_device_command_set_date_time (DeviceInterface
*device
,
170 const char* date_time
)
172 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
173 gsmd_modem_post_at_command_id( modem
,
184 * @brief Handler to modems response from setDateTime command
186 * @param modem modem whose response to handle
187 * @return true if responses were recognized
190 AtCommandHandlerStatus
gsmd_device_handler_set_date_time (ModemInterface
*modem
,
191 AtCommandContext
*at
, GString
*response
)
193 GScanner
* scanner
= modem
->scanner
;
194 // g_message ("Set datatime handler\n");
195 if (scanner
->token
== SYMBOL_OK
) {
196 //TODO smartphone doesn't have datetime methods so they need
197 //to be specified or this code moved elsewhere
199 if (modem->modem_interface->setDateTimeResp)
200 modem->modem_interface->setDateTimeResp (modem,TRUE);
202 return AT_HANDLER_DONE
;
203 } else if (scanner
->token
== SYMBOL_ERROR
) { //if format uncorrect,
204 //TODO smartphone doesn't have datetime methods so they need to
205 //be specified or this code moved elsewhere
207 if (modem->modem_interface->setDateTimeResp)
208 modem->modem_interface->setDateTimeResp (modem,FALSE);
210 return AT_HANDLER_DONE
;
212 if (scanner
->token
== SYMBOL_TIME_OUT
) {
213 return AT_HANDLER_DONE
;
215 return AT_HANDLER_DONT_UNDERSTAND
;
219 * @brief Handler to modems response from queryDateTime command
221 * @param modem modem whose response to handle
222 * @return true if responses were recognized
225 AtCommandHandlerStatus
gsmd_device_handler_query_date_time (ModemInterface
*modem
,
226 AtCommandContext
*at
,
229 GScanner
* scanner
= modem
->scanner
;
230 // g_message ("Query datatime handler\n");
232 // +CCLK: "02/09/07,22:30:25"
233 if (gsmd_utils_check_end_token(scanner
)) {
234 return AT_HANDLER_DONE
;
236 if (scanner
->token
== SYMBOL_TIME_OUT
) {
237 return AT_HANDLER_DONE
;
239 if (scanner
->token
!= '+')
240 return AT_HANDLER_DONT_UNDERSTAND
;
241 g_scanner_get_next_token (scanner
);
242 if (scanner
->token
== SYMBOL_CCLK
) {
243 g_scanner_get_next_token (scanner
);//get :
244 g_scanner_get_next_token (scanner
);//get string
245 GString
* date_time_str
= g_string_new (scanner
->value
.v_string
);
246 /* //TODO datetime methods arent specified in freesmartphone's api
247 if (modem->device->dateTime)
248 modem->device->dateTime (modem,date_time_str);
250 g_string_free (date_time_str
, TRUE
);
251 return AT_HANDLER_DONE
;
253 return AT_HANDLER_DONT_UNDERSTAND
;
257 AtCommandHandlerStatus
gsmd_device_get_info_handler(ModemInterface
* modem
,
258 AtCommandContext
*at
,
261 const gchar
*errormsg
,
262 const gchar
*timeoutmsg
)
264 GScanner
* scanner
= modem
->scanner
;
267 if (scanner
->token
== SYMBOL_OK
) {
268 val
= g_hash_table_lookup(at
->handler_data
,key
);
270 gsmd_utils_send_error(at
,GSMD_ERROR_UNKNOWN
,"OK WITHOUT RESPONSE");
271 g_warning("%s : Invalid handler data: %p",
275 return AT_HANDLER_DONE_ERROR
;
278 return AT_HANDLER_DONE
;
279 } else if (scanner
->token
== G_TOKEN_EOF
) {
280 return AT_HANDLER_NEED_MORE
;
281 } else if (gsmd_utils_send_error_from_response(at
,
285 return AT_HANDLER_DONE_ERROR
;
288 return AT_HANDLER_DONT_UNDERSTAND
;
292 AtCommandHandlerStatus
gsmd_device_handler_query_imei ( ModemInterface
* modem
,
293 AtCommandContext
*at
,
297 AtCommandHandlerStatus status
= gsmd_device_get_info_handler(modem
,
300 GSMD_DEVICE_KEY_IMEI
,
301 "ERROR OCCURRED WHEN QUERYING IMEI",
302 "TIMEOUT OCCURRED WHEN QUERYING IMEI");
303 if (status
!= AT_HANDLER_DONT_UNDERSTAND
) {
306 GScanner
* scanner
= modem
->scanner
;
308 if ( scanner
->token
== '+' ) {
309 g_scanner_get_next_token (scanner
);
310 if ( scanner
->token
== SYMBOL_CGSN
) {
311 g_scanner_get_next_token (scanner
);
312 if (scanner
->token
== ':') {
313 g_scanner_peek_next_token (scanner
);
314 if ( scanner
->next_token
== G_TOKEN_INT
) {
315 res
= g_strdup(response
->str
+g_scanner_cur_position(scanner
));
316 res
= g_strstrip(res
);
321 res
= g_strdup(response
->str
);
322 res
= g_strstrip(res
);
325 gboolean is_imei
= TRUE
;
327 if ( strlen(res
) == 15 ) {
328 for (i
=0; i
< 15;i
++) {
329 if ( !g_ascii_isdigit(res
[i
]) ) {
338 g_debug("%s : %s is not IMEI",__func__
, res
);
340 return AT_HANDLER_DONT_UNDERSTAND
;
343 g_debug("%s : IMEI: %s",__func__
, res
);
345 gsmd_utils_table_insert_string(at
->handler_data
,GSMD_DEVICE_KEY_IMEI
,res
);
349 return AT_HANDLER_NEED_MORE
;
352 AtCommandHandlerStatus
gsmd_device_handler_query_revision (ModemInterface
*modem
,
353 AtCommandContext
*at
,
356 g_debug("%s : %s",__func__
, response
->str
);
357 AtCommandHandlerStatus status
= gsmd_device_get_info_handler(modem
,
360 GSMD_DEVICE_KEY_MODEM_REVISION
,
361 "ERROR OCCURRED WHEN QUERYING REVISION",
362 "TIMEOUT OCCURRED WHEN QUERYING REVISION");
363 if (status
!= AT_HANDLER_DONT_UNDERSTAND
)
367 GScanner
* scanner
= modem
->scanner
;
369 if ( scanner
->token
== '+' ) {
370 g_scanner_get_next_token (scanner
);
371 if ( scanner
->token
== SYMBOL_CGMR
) {
372 g_scanner_get_next_token (scanner
);
373 if (scanner
->token
== ':') {
374 g_scanner_peek_next_token (scanner
);
375 if ( scanner
->next_token
== G_TOKEN_STRING
) {
376 g_scanner_get_next_token (scanner
);
377 res
= g_strdup(scanner
->value
.v_string
);
379 res
= g_strdup(response
->str
+g_scanner_cur_position(scanner
));
380 res
= g_strstrip(res
);
382 g_debug("%s : manu: '%s'", __func__
, res
);
386 res
= g_strdup(response
->str
);
387 res
= g_strstrip(res
);
389 if ( res
&& strlen(res
) > 0 ) {
390 g_debug("%s : SW revision: %s",__func__
, res
);
391 gsmd_utils_table_insert_string(at
->handler_data
,
392 GSMD_DEVICE_KEY_MODEM_REVISION
,
397 return AT_HANDLER_NEED_MORE
;
400 AtCommandHandlerStatus
gsmd_device_handler_query_manufacturer (ModemInterface
*modem
,
401 AtCommandContext
*at
,
404 /* g_debug("%s : %s",__func__, response->str); */
405 AtCommandHandlerStatus status
= gsmd_device_get_info_handler(modem
,
408 GSMD_DEVICE_KEY_MODEM_VENDOR
,
409 "ERROR OCCURRED WHEN QUERYING MANUFACTURE",
410 "TIMEOUT OCCURRED WHEN QUERYING MANUFACTURER");
411 if (status
!= AT_HANDLER_DONT_UNDERSTAND
)
414 GScanner
* scanner
= modem
->scanner
;
416 if ( scanner
->token
== '+' ) {
417 g_scanner_get_next_token (scanner
);
418 if ( scanner
->token
== SYMBOL_CGMI
) {
419 g_scanner_get_next_token (scanner
);
420 if (scanner
->token
== ':') {
421 g_scanner_peek_next_token (scanner
);
422 if ( scanner
->next_token
== G_TOKEN_STRING
) {
423 g_scanner_get_next_token (scanner
);
424 res
= g_strdup(scanner
->value
.v_string
);
426 res
= g_strdup(response
->str
+g_scanner_cur_position(scanner
));
427 res
= g_strstrip(res
);
429 g_debug("%s : manu: '%s'", __func__
, res
);
433 res
= g_strdup(response
->str
);
434 res
= g_strstrip(res
);
436 if ( res
&& strlen(res
) > 0 ) {
437 g_debug("%s : manufacturer: %s",__func__
, res
);
438 gsmd_utils_table_insert_string(at
->handler_data
,
439 GSMD_DEVICE_KEY_MODEM_VENDOR
,
445 return AT_HANDLER_NEED_MORE
;
448 AtCommandHandlerStatus
gsmd_device_handler_query_model (ModemInterface
*modem
,
449 AtCommandContext
*at
,
452 g_debug("%s : %s",__func__
, response
->str
);
453 AtCommandHandlerStatus status
= gsmd_device_get_info_handler(modem
,
456 GSMD_DEVICE_KEY_MODEM_MODEL
,
457 "ERROR OCCURRED WHEN QUERYING MODEL",
458 "TIMEOUT OCCURRED WHEN QUERYING MODEL");
459 if (status
!= AT_HANDLER_DONT_UNDERSTAND
)
462 GScanner
* scanner
= modem
->scanner
;
464 if ( scanner
->token
== '+' ) {
465 g_scanner_get_next_token (scanner
);
466 if ( scanner
->token
== SYMBOL_CGMM
) {
467 g_scanner_get_next_token (scanner
);
468 if (scanner
->token
== ':') {
469 g_scanner_peek_next_token (scanner
);
470 if ( scanner
->next_token
== G_TOKEN_STRING
) {
471 g_scanner_get_next_token (scanner
);
472 res
= g_strdup(scanner
->value
.v_string
);
474 res
= g_strdup(response
->str
+g_scanner_cur_position(scanner
));
475 res
= g_strstrip(res
);
477 g_debug("%s : manu: '%s'", __func__
, res
);
481 res
= g_strdup(response
->str
);
482 res
= g_strstrip(res
);
484 if ( res
&& strlen(res
) > 0 ) {
485 g_debug("%s : model: %s",__func__
, res
);
486 gsmd_utils_table_insert_string(at
->handler_data
,
487 GSMD_DEVICE_KEY_MODEM_MODEL
,
492 return AT_HANDLER_NEED_MORE
;
496 static gboolean
gsmd_device_command_get_info_reply(ModemInterface
*modem
,
500 if( !modem
->no_cache
) {
501 GValue
*vendor
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_VENDOR
);
502 GValue
*model
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_MODEL
);
503 GValue
*revision
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_REVISION
);
504 GValue
*imei
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_IMEI
);
507 gsmd_utils_table_insert_copy(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_VENDOR
,vendor
);
510 gsmd_utils_table_insert_copy(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_MODEL
,model
);
513 gsmd_utils_table_insert_copy(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_REVISION
,revision
);
516 gsmd_utils_table_insert_copy(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_IMEI
,imei
);
519 modem
->device_ipc
->get_info_reply( modem
->device_ipc
,
526 AtCommandHandlerStatus
gsmd_device_handler_get_info (ModemInterface
*modem
,
527 AtCommandContext
*at
,
530 AtCommandHandlerStatus status
= AT_HANDLER_DONT_UNDERSTAND
;
531 AtCommandContext
*cmd
= NULL
;
532 switch (at
->command
->cmd_id
) {
534 g_debug("%s : IMEI_QUERY", __func__
);
535 /* status = gsmd_device_handler_query_imei(modem,at,response); */
536 status
= at
->command
->handler(modem
,at
,response
);
538 case AT_HANDLER_DONE_ERROR
:
539 case AT_HANDLER_ERROR
:
540 return AT_HANDLER_DONE_ERROR
;
542 case AT_HANDLER_DONE
:
543 cmd
= gsmd_at_command_context_new_from_id( modem
,
550 at
->handler_data
= NULL
;
551 cmd
->handler
= &gsmd_device_handler_get_info
;
552 gsmd_modem_post_at_command(modem
,cmd
,INTERFACE_DEVICE
);
553 status
= AT_HANDLER_DONE
;
555 case AT_HANDLER_DONT_UNDERSTAND
:
556 case AT_HANDLER_NEED_MORE
:
557 case AT_HANDLER_RETRY
:
561 case MANUFACTURER_QUERY
:
562 g_debug("%s : MANUFACTURER_QUERY", __func__
);
563 status
= at
->command
->handler(modem
,at
,response
);
565 case AT_HANDLER_DONE_ERROR
:
566 case AT_HANDLER_ERROR
:
567 return AT_HANDLER_DONE_ERROR
;
568 case AT_HANDLER_DONE
:
569 cmd
= gsmd_at_command_context_new_from_id( modem
,
576 at
->handler_data
= NULL
;
577 cmd
->handler
= &gsmd_device_handler_get_info
;
578 gsmd_modem_post_at_command(modem
,cmd
,INTERFACE_DEVICE
);
579 status
= AT_HANDLER_DONE
;
581 case AT_HANDLER_DONT_UNDERSTAND
:
582 case AT_HANDLER_NEED_MORE
:
583 case AT_HANDLER_RETRY
:
587 case SW_REVISION_QUERY
:
588 g_debug("%s : SW_REVISION_QUERY", __func__
);
589 status
= at
->command
->handler(modem
,at
,response
);
591 case AT_HANDLER_DONE_ERROR
:
592 case AT_HANDLER_ERROR
:
593 return AT_HANDLER_DONE_ERROR
;
594 case AT_HANDLER_DONE
:
595 cmd
= gsmd_at_command_context_new_from_id( modem
,
602 at
->handler_data
= NULL
;
603 cmd
->handler
= &gsmd_device_handler_get_info
;
604 gsmd_modem_post_at_command(modem
,cmd
,INTERFACE_DEVICE
);
605 status
= AT_HANDLER_DONE
;
607 case AT_HANDLER_DONT_UNDERSTAND
:
608 case AT_HANDLER_NEED_MORE
:
609 case AT_HANDLER_RETRY
:
614 g_debug("%s : MODEL_QUERY", __func__
);
615 status
= gsmd_device_handler_query_model(modem
,at
,response
);
617 case AT_HANDLER_DONE_ERROR
:
618 case AT_HANDLER_ERROR
:
619 return AT_HANDLER_DONE_ERROR
;
621 case AT_HANDLER_DONE
:
622 gsmd_device_command_get_info_reply(modem
,at
->ipc_data
, at
->handler_data
);
625 case AT_HANDLER_DONT_UNDERSTAND
:
626 case AT_HANDLER_NEED_MORE
:
627 case AT_HANDLER_RETRY
:
637 void gsmd_device_command_get_info( DeviceInterface
*device
, gpointer ipc_data
)
639 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
640 GValue
*vendor
= NULL
;
641 GValue
*model
= NULL
;
642 GValue
*revision
= NULL
;
644 if ( !modem
->no_cache
) {
645 vendor
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_VENDOR
);
646 model
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_MODEL
);
647 revision
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_REVISION
);
648 imei
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_IMEI
);
650 if (vendor
&& model
&& revision
&& imei
) {
651 g_debug("%s: info is cached",__func__
);
652 GHashTable
*info
= gsmd_utils_create_hash_table();
653 gsmd_utils_table_insert_copy(info
,GSMD_DEVICE_KEY_MODEM_VENDOR
,vendor
);
654 gsmd_utils_table_insert_copy(info
,GSMD_DEVICE_KEY_MODEM_MODEL
,model
);
655 gsmd_utils_table_insert_copy(info
,GSMD_DEVICE_KEY_MODEM_REVISION
,revision
);
656 gsmd_utils_table_insert_copy(info
,GSMD_DEVICE_KEY_IMEI
,imei
);
657 modem
->device_ipc
->get_info_reply(modem
->device_ipc
,
660 g_hash_table_destroy(info
);
663 AtCommandContext
*cmd
= NULL
;
664 cmd
= gsmd_at_command_context_new_from_id( modem
,
668 (ErrorFunction
)modem
->device_ipc
->get_info_error
,
671 cmd
->handler
= &gsmd_device_handler_get_info
;
672 gsmd_modem_post_at_command(modem
,cmd
,INTERFACE_DEVICE
);
677 void gsmd_device_command_set_antenna_power( DeviceInterface
*device
,
679 gboolean antenna_power
)
686 AtCommandHandlerStatus
gsmd_device_handler_get_antenna_power (ModemInterface
*modem
,
687 AtCommandContext
*at
,
690 GScanner
* scanner
= modem
->scanner
;
692 // g_message ("Query datatime handler\n");
694 // +CCLK: "02/09/07,22:30:25"
695 if (scanner
->token
== SYMBOL_OK
) {
696 val
= g_hash_table_lookup(at
->handler_data
,GSMD_DEVICE_KEY_POWER
);
700 g_warning("%s : Invalid handler data. power: %p",
704 gsmd_utils_send_error(at
,
706 "OK WITHOUT RESPONSE");
711 return AT_HANDLER_DONE_ERROR
;
714 modem
->device_ipc
->get_antenna_power_reply(modem
->device_ipc
,
716 g_value_get_boolean(val
));
718 gsmd_utils_table_insert_copy(modem
->caches
[INTERFACE_DEVICE
],
719 GSMD_DEVICE_KEY_POWER
,
721 return AT_HANDLER_DONE
;
725 if (gsmd_utils_send_error_from_response(at
,
727 "FAILED TO GET ANTENNA POWER",
728 "TIMEOUT WHEN GETTING ANTENNA POWER")) {
729 return AT_HANDLER_DONE_ERROR
;
732 if (scanner
->token
!= '+') {
733 return AT_HANDLER_DONT_UNDERSTAND
;
735 g_scanner_get_next_token (scanner
);
736 if (scanner
->token
== SYMBOL_CFUN
) {
737 g_scanner_get_next_token (scanner
);//get :
738 g_scanner_get_next_token (scanner
);//get string
740 gsmd_utils_table_insert_boolean(at
->handler_data
,
741 GSMD_DEVICE_KEY_POWER
,
742 scanner
->value
.v_int
);
743 return AT_HANDLER_NEED_MORE
;
745 return AT_HANDLER_DONT_UNDERSTAND
;
748 void gsmd_device_command_get_antenna_power( DeviceInterface
*device
,
751 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
752 if (modem
->no_cache
|| !g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_POWER
)) {
753 gsmd_modem_post_at_command_id( modem
,
757 (ErrorFunction
)modem
->device_ipc
->get_antenna_power_error
,
758 (gpointer
)modem
->device_ipc
,
762 GValue
*val
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_POWER
);
764 modem
->device_ipc
->get_antenna_power_reply(modem
->device_ipc
,
766 g_value_get_boolean(val
));
773 void gsmd_device_command_prepare_to_suspend( DeviceInterface
*device
,
776 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
777 modem
->device_ipc
->prepare_to_suspend_reply(modem
->device_ipc
,
781 void gsmd_device_command_recover_from_suspend( DeviceInterface
*device
,
784 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
785 modem
->device_ipc
->recover_from_suspend_reply(modem
->device_ipc
,
789 void gsmd_device_command_get_features( DeviceInterface
*device
, gpointer ipc_data
)
791 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
792 GHashTable
*table
= gsmd_utils_create_hash_table();
794 modem
->device_ipc
->get_features_reply( modem
->device_ipc
,
797 g_hash_table_destroy(table
);
801 void gsmd_device_init(ModemInterface
*modem
)
803 gsmd_device_init_at_handler(modem
);
805 modem
->device
->priv
= (gpointer
)modem
;
806 modem
->device
->prepare_to_suspend
= &gsmd_device_command_prepare_to_suspend
;
807 modem
->device
->recover_from_suspend
= &gsmd_device_command_recover_from_suspend
;
808 modem
->device
->get_date_time
= &gsmd_device_command_query_date_time
;
809 modem
->device
->set_date_time
= &gsmd_device_command_set_date_time
;
810 modem
->device
->get_info
= &gsmd_device_command_get_info
;
811 modem
->device
->set_antenna_power
= &gsmd_device_command_set_antenna_power
;
812 modem
->device
->get_antenna_power
= &gsmd_device_command_get_antenna_power
;
813 modem
->device
->get_features
= &gsmd_device_command_get_features
;