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 g_debug("%s", __func__
);
134 while (device_symbol_p
->symbol_name
) {
135 g_scanner_add_symbol (modem
->scanner
, device_symbol_p
->symbol_name
,
136 GINT_TO_POINTER(device_symbol_p
->symbol_token
));
139 while (device_command_p
->command
) {
140 gsmd_modem_register_command (modem
,device_command_p
);
146 * @brief AtCommand to query datetime
148 * @param modem modem whose response to handle
150 static void gsmd_device_command_query_date_time (DeviceInterface
*device
,
153 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
154 gsmd_modem_post_at_command_id( modem
,
165 * @brief AtCommand to set datetime
167 * @param modem modem whose response to handle
168 * @param date_time datetime to set. Format "yy/MM/dd,hh:mm:ss±zz"
170 static void gsmd_device_command_set_date_time (DeviceInterface
*device
,
172 const char* date_time
)
174 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
175 gsmd_modem_post_at_command_id( modem
,
186 * @brief Handler to modems response from setDateTime command
188 * @param modem modem whose response to handle
189 * @return true if responses were recognized
192 AtCommandHandlerStatus
gsmd_device_handler_set_date_time (ModemInterface
*modem
,
193 AtCommandContext
*at
, GString
*response
)
195 GScanner
* scanner
= modem
->scanner
;
196 // g_message ("Set datatime handler\n");
197 if (scanner
->token
== SYMBOL_OK
) {
198 //TODO smartphone doesn't have datetime methods so they need
199 //to be specified or this code moved elsewhere
201 if (modem->modem_interface->setDateTimeResp)
202 modem->modem_interface->setDateTimeResp (modem,TRUE);
204 return AT_HANDLER_DONE
;
205 } else if (scanner
->token
== SYMBOL_ERROR
) { //if format uncorrect,
206 //TODO smartphone doesn't have datetime methods so they need to
207 //be specified or this code moved elsewhere
209 if (modem->modem_interface->setDateTimeResp)
210 modem->modem_interface->setDateTimeResp (modem,FALSE);
212 return AT_HANDLER_DONE
;
214 if (scanner
->token
== SYMBOL_TIME_OUT
) {
215 return AT_HANDLER_DONE
;
217 return AT_HANDLER_DONT_UNDERSTAND
;
221 * @brief Handler to modems response from queryDateTime command
223 * @param modem modem whose response to handle
224 * @return true if responses were recognized
227 AtCommandHandlerStatus
gsmd_device_handler_query_date_time (ModemInterface
*modem
,
228 AtCommandContext
*at
,
231 GScanner
* scanner
= modem
->scanner
;
232 // g_message ("Query datatime handler\n");
234 // +CCLK: "02/09/07,22:30:25"
235 if (gsmd_utils_check_end_token(scanner
)) {
236 return AT_HANDLER_DONE
;
238 if (scanner
->token
== SYMBOL_TIME_OUT
) {
239 return AT_HANDLER_DONE
;
241 if (scanner
->token
!= '+')
242 return AT_HANDLER_DONT_UNDERSTAND
;
243 g_scanner_get_next_token (scanner
);
244 if (scanner
->token
== SYMBOL_CCLK
) {
245 g_scanner_get_next_token (scanner
);//get :
246 g_scanner_get_next_token (scanner
);//get string
247 GString
* date_time_str
= g_string_new (scanner
->value
.v_string
);
248 /* //TODO datetime methods arent specified in freesmartphone's api
249 if (modem->device->dateTime)
250 modem->device->dateTime (modem,date_time_str);
252 g_string_free (date_time_str
, TRUE
);
253 return AT_HANDLER_DONE
;
255 return AT_HANDLER_DONT_UNDERSTAND
;
259 AtCommandHandlerStatus
gsmd_device_get_info_handler(ModemInterface
* modem
,
260 AtCommandContext
*at
,
262 const gchar
*errormsg
,
263 const gchar
*timeoutmsg
)
265 GScanner
* scanner
= modem
->scanner
;
268 if (scanner
->token
== SYMBOL_OK
) {
269 val
= g_hash_table_lookup(at
->handler_data
,key
);
271 gsmd_utils_send_error(at
,GSMD_ERROR_UNKNOWN
,"INVALID HANDLER DATA");
272 g_warning("%s : Invalid handler data: %p",
276 return AT_HANDLER_DONE_ERROR
;
279 gsmd_utils_table_insert_copy(modem
->caches
[INTERFACE_DEVICE
],key
,val
);
281 return AT_HANDLER_DONE
;
282 } else if (scanner
->token
== G_TOKEN_EOF
) {
283 return AT_HANDLER_NEED_MORE
;
284 } else if (gsmd_utils_send_error_from_response(at
,
288 return AT_HANDLER_DONE_ERROR
;
291 return AT_HANDLER_DONT_UNDERSTAND
;
295 AtCommandHandlerStatus
gsmd_device_handler_query_imei ( ModemInterface
* modem
,
296 AtCommandContext
*at
,
300 AtCommandHandlerStatus status
= gsmd_device_get_info_handler(modem
,
302 GSMD_DEVICE_KEY_IMEI
,
303 "ERROR OCCURRED WHEN QUERYING IMEI",
304 "TIMEOUT OCCURRED WHEN QUERYING IMEI");
305 if (status
!= AT_HANDLER_DONT_UNDERSTAND
) {
308 GScanner
* scanner
= modem
->scanner
;
310 if ( scanner
->token
== '+' ) {
311 g_scanner_get_next_token (scanner
);
312 if ( scanner
->token
== SYMBOL_CGSN
) {
313 g_scanner_get_next_token (scanner
);
314 if (scanner
->token
== ':') {
315 g_scanner_peek_next_token (scanner
);
316 if ( scanner
->next_token
== G_TOKEN_INT
) {
317 res
= g_strdup(response
->str
+g_scanner_cur_position(scanner
));
318 res
= g_strstrip(res
);
323 res
= g_strdup(response
->str
);
324 res
= g_strstrip(res
);
327 gboolean is_imei
= TRUE
;
329 if ( strlen(res
) == 15 ) {
330 for (i
=0; i
< 15;i
++) {
331 if ( !g_ascii_isdigit(res
[i
]) ) {
340 g_debug("%s : %s is not IMEI",__func__
, res
);
342 return AT_HANDLER_DONT_UNDERSTAND
;
345 g_debug("%s : IMEI: %s",__func__
, res
);
347 gsmd_utils_table_insert_string(at
->handler_data
,GSMD_DEVICE_KEY_IMEI
,res
);
351 return AT_HANDLER_NEED_MORE
;
354 AtCommandHandlerStatus
gsmd_device_handler_query_revision (ModemInterface
*modem
,
355 AtCommandContext
*at
,
358 g_debug("%s : %s",__func__
, response
->str
);
359 AtCommandHandlerStatus status
= gsmd_device_get_info_handler(modem
,
361 GSMD_DEVICE_KEY_MODEM_REVISION
,
362 "ERROR OCCURRED WHEN QUERYING REVISION",
363 "TIMEOUT OCCURRED WHEN QUERYING REVISION");
364 if (status
!= AT_HANDLER_DONT_UNDERSTAND
)
368 GScanner
* scanner
= modem
->scanner
;
370 if ( scanner
->token
== '+' ) {
371 g_scanner_get_next_token (scanner
);
372 if ( scanner
->token
== SYMBOL_CGMR
) {
373 g_scanner_get_next_token (scanner
);
374 if (scanner
->token
== ':') {
375 g_scanner_peek_next_token (scanner
);
376 if ( scanner
->next_token
== G_TOKEN_STRING
) {
377 g_scanner_get_next_token (scanner
);
378 res
= g_strdup(scanner
->value
.v_string
);
380 res
= g_strdup(response
->str
+g_scanner_cur_position(scanner
));
381 res
= g_strstrip(res
);
383 g_debug("%s : manu: '%s'", __func__
, res
);
387 res
= g_strdup(response
->str
);
388 res
= g_strstrip(res
);
390 if ( res
&& strlen(res
) > 0 ) {
391 g_debug("%s : SW revision: %s",__func__
, res
);
392 gsmd_utils_table_insert_string(at
->handler_data
,
393 GSMD_DEVICE_KEY_MODEM_REVISION
,
398 return AT_HANDLER_NEED_MORE
;
401 AtCommandHandlerStatus
gsmd_device_handler_query_manufacturer (ModemInterface
*modem
,
402 AtCommandContext
*at
,
405 g_debug("%s : %s",__func__
, response
->str
);
406 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
,
455 GSMD_DEVICE_KEY_MODEM_MODEL
,
456 "ERROR OCCURRED WHEN QUERYING MODEL",
457 "TIMEOUT OCCURRED WHEN QUERYING MODEL");
458 if (status
!= AT_HANDLER_DONT_UNDERSTAND
)
461 GScanner
* scanner
= modem
->scanner
;
463 if ( scanner
->token
== '+' ) {
464 g_scanner_get_next_token (scanner
);
465 if ( scanner
->token
== SYMBOL_CGMM
) {
466 g_scanner_get_next_token (scanner
);
467 if (scanner
->token
== ':') {
468 g_scanner_peek_next_token (scanner
);
469 if ( scanner
->next_token
== G_TOKEN_STRING
) {
470 g_scanner_get_next_token (scanner
);
471 res
= g_strdup(scanner
->value
.v_string
);
473 res
= g_strdup(response
->str
+g_scanner_cur_position(scanner
));
474 res
= g_strstrip(res
);
476 g_debug("%s : manu: '%s'", __func__
, res
);
480 res
= g_strdup(response
->str
);
481 res
= g_strstrip(res
);
483 if ( res
&& strlen(res
) > 0 ) {
484 g_debug("%s : model: %s",__func__
, res
);
485 gsmd_utils_table_insert_string(at
->handler_data
,
486 GSMD_DEVICE_KEY_MODEM_MODEL
,
491 return AT_HANDLER_NEED_MORE
;
495 static gboolean
gsmd_device_command_get_info_reply(ModemInterface
*modem
,
498 GValue
*vendor
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_VENDOR
);
499 GValue
*model
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_MODEL
);
500 GValue
*revision
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_REVISION
);
501 GValue
*imei
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_IMEI
);
504 if (!vendor
|| !model
|| !revision
|| !imei
)
508 GHashTable
*table
= gsmd_utils_create_hash_table();
510 gsmd_utils_table_insert_copy(table
,GSMD_DEVICE_KEY_MODEM_VENDOR
,vendor
);
511 gsmd_utils_table_insert_copy(table
,GSMD_DEVICE_KEY_MODEM_MODEL
,model
);
512 gsmd_utils_table_insert_copy(table
,GSMD_DEVICE_KEY_MODEM_REVISION
,revision
);
513 gsmd_utils_table_insert_copy(table
,GSMD_DEVICE_KEY_IMEI
,imei
);
515 modem
->device_ipc
->get_info_reply( modem
->device_ipc
,
518 g_hash_table_destroy(table
);
523 AtCommandHandlerStatus
gsmd_device_handler_get_info (ModemInterface
*modem
,
524 AtCommandContext
*at
,
527 AtCommandHandlerStatus status
= AT_HANDLER_DONT_UNDERSTAND
;
528 AtCommandContext
*cmd
= NULL
;
529 switch (at
->command
->cmd_id
) {
531 g_debug("%s : IMEI_QUERY", __func__
);
532 /* status = gsmd_device_handler_query_imei(modem,at,response); */
533 status
= at
->command
->handler(modem
,at
,response
);
535 case AT_HANDLER_DONE_ERROR
:
536 case AT_HANDLER_ERROR
:
537 return AT_HANDLER_DONE_ERROR
;
539 case AT_HANDLER_DONE
:
540 if ( !g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_IMEI
) ) {
541 gsmd_utils_send_error(at
,GSMD_ERROR_UNKNOWN
,"UNABLE TO READ IMEI");
542 return AT_HANDLER_DONE_ERROR
;
544 g_hash_table_remove(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_VENDOR
);
546 cmd
= gsmd_at_command_context_new_from_id( modem
,
553 cmd
->handler
= &gsmd_device_handler_get_info
;
554 gsmd_modem_post_at_command(modem
,cmd
,INTERFACE_DEVICE
);
555 status
= AT_HANDLER_DONE
;
557 case AT_HANDLER_DONT_UNDERSTAND
:
558 case AT_HANDLER_NEED_MORE
:
559 case AT_HANDLER_RETRY
:
563 case MANUFACTURER_QUERY
:
564 g_debug("%s : MANUFACTURER_QUERY", __func__
);
565 status
= at
->command
->handler(modem
,at
,response
);
567 case AT_HANDLER_DONE_ERROR
:
568 case AT_HANDLER_ERROR
:
569 return AT_HANDLER_DONE_ERROR
;
570 case AT_HANDLER_DONE
:
571 if ( !g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_VENDOR
) ) {
572 gsmd_utils_send_error(at
,GSMD_ERROR_UNKNOWN
,"UNABLE TO READ MANUFACTURER");
573 return AT_HANDLER_DONE_ERROR
;
576 g_hash_table_remove(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_REVISION
);
577 cmd
= gsmd_at_command_context_new_from_id( modem
,
584 cmd
->handler
= &gsmd_device_handler_get_info
;
585 gsmd_modem_post_at_command(modem
,cmd
,INTERFACE_DEVICE
);
586 status
= AT_HANDLER_DONE
;
588 case AT_HANDLER_DONT_UNDERSTAND
:
589 case AT_HANDLER_NEED_MORE
:
590 case AT_HANDLER_RETRY
:
594 case SW_REVISION_QUERY
:
595 g_debug("%s : SW_REVISION_QUERY", __func__
);
596 status
= at
->command
->handler(modem
,at
,response
);
598 case AT_HANDLER_DONE_ERROR
:
599 case AT_HANDLER_ERROR
:
600 return AT_HANDLER_DONE_ERROR
;
601 case AT_HANDLER_DONE
:
602 if ( !g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_REVISION
) ) {
603 gsmd_utils_send_error(at
,GSMD_ERROR_UNKNOWN
,"UNABLE TO READ SW REVISION");
604 return AT_HANDLER_DONE_ERROR
;
607 g_hash_table_remove(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_MODEM_MODEL
);
608 cmd
= gsmd_at_command_context_new_from_id( modem
,
615 cmd
->handler
= &gsmd_device_handler_get_info
;
616 gsmd_modem_post_at_command(modem
,cmd
,INTERFACE_DEVICE
);
617 status
= AT_HANDLER_DONE
;
619 case AT_HANDLER_DONT_UNDERSTAND
:
620 case AT_HANDLER_NEED_MORE
:
621 case AT_HANDLER_RETRY
:
626 g_debug("%s : MODEL_QUERY", __func__
);
627 status
= gsmd_device_handler_query_model(modem
,at
,response
);
629 case AT_HANDLER_DONE_ERROR
:
630 case AT_HANDLER_ERROR
:
631 return AT_HANDLER_DONE_ERROR
;
633 case AT_HANDLER_DONE
:
634 gsmd_device_command_get_info_reply(modem
,at
->ipc_data
);
637 case AT_HANDLER_DONT_UNDERSTAND
:
638 case AT_HANDLER_NEED_MORE
:
639 case AT_HANDLER_RETRY
:
649 void gsmd_device_command_get_info( DeviceInterface
*device
, gpointer ipc_data
)
651 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
652 if (modem
->no_cache
|| !gsmd_device_command_get_info_reply(modem
,ipc_data
)) {
653 g_hash_table_remove(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_IMEI
);
654 AtCommandContext
*cmd
= NULL
;
655 cmd
= gsmd_at_command_context_new_from_id( modem
,
659 (ErrorFunction
)modem
->device_ipc
->get_info_error
,
662 cmd
->handler
= &gsmd_device_handler_get_info
;
663 gsmd_modem_post_at_command(modem
,cmd
,INTERFACE_DEVICE
);
668 void gsmd_device_command_set_antenna_power( DeviceInterface
*device
,
670 gboolean antenna_power
)
677 AtCommandHandlerStatus
gsmd_device_handler_get_antenna_power (ModemInterface
*modem
,
678 AtCommandContext
*at
,
681 GScanner
* scanner
= modem
->scanner
;
683 // g_message ("Query datatime handler\n");
685 // +CCLK: "02/09/07,22:30:25"
686 if (scanner
->token
== SYMBOL_OK
) {
687 val
= g_hash_table_lookup(at
->handler_data
,GSMD_DEVICE_KEY_POWER
);
691 g_warning("%s : Invalid handler data. power: %p",
695 gsmd_utils_send_error(at
,
697 "INVALID HANDLER DATA");
702 return AT_HANDLER_DONE_ERROR
;
705 modem
->device_ipc
->get_antenna_power_reply(modem
->device_ipc
,
707 g_value_get_boolean(val
));
709 gsmd_utils_table_insert_copy(modem
->caches
[INTERFACE_DEVICE
],
710 GSMD_DEVICE_KEY_POWER
,
712 return AT_HANDLER_DONE
;
716 if (gsmd_utils_send_error_from_response(at
,
718 "FAILED TO GET ANTENNA POWER",
719 "TIMEOUT WHEN GETTING ANTENNA POWER")) {
720 return AT_HANDLER_DONE_ERROR
;
723 if (scanner
->token
!= '+') {
724 return AT_HANDLER_DONT_UNDERSTAND
;
726 g_scanner_get_next_token (scanner
);
727 if (scanner
->token
== SYMBOL_CFUN
) {
728 g_scanner_get_next_token (scanner
);//get :
729 g_scanner_get_next_token (scanner
);//get string
731 gsmd_utils_table_insert_boolean(at
->handler_data
,
732 GSMD_DEVICE_KEY_POWER
,
733 scanner
->value
.v_int
);
734 return AT_HANDLER_NEED_MORE
;
736 return AT_HANDLER_DONT_UNDERSTAND
;
739 void gsmd_device_command_get_antenna_power( DeviceInterface
*device
,
742 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
743 if (modem
->no_cache
|| !g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_POWER
)) {
744 gsmd_modem_post_at_command_id( modem
,
748 (ErrorFunction
)modem
->device_ipc
->get_antenna_power_error
,
749 (gpointer
)modem
->device_ipc
,
753 GValue
*val
= g_hash_table_lookup(modem
->caches
[INTERFACE_DEVICE
],GSMD_DEVICE_KEY_POWER
);
755 modem
->device_ipc
->get_antenna_power_reply(modem
->device_ipc
,
757 g_value_get_boolean(val
));
764 void gsmd_device_command_prepare_to_suspend( DeviceInterface
*device
,
769 void gsmd_device_command_recover_from_suspend( DeviceInterface
*device
,
774 void gsmd_device_command_get_features( DeviceInterface
*device
, gpointer ipc_data
)
776 ModemInterface
*modem
= (ModemInterface
*)device
->priv
;
777 GHashTable
*table
= gsmd_utils_create_hash_table();
779 modem
->device_ipc
->get_features_reply( modem
->device_ipc
,
782 g_hash_table_destroy(table
);
786 void gsmd_device_init(ModemInterface
*modem
)
788 gsmd_device_init_at_handler(modem
);
790 modem
->device
->priv
= (gpointer
)modem
;
791 modem
->device
->prepare_to_suspend
= &gsmd_device_command_prepare_to_suspend
;
792 modem
->device
->recover_from_suspend
= &gsmd_device_command_recover_from_suspend
;
793 modem
->device
->get_date_time
= &gsmd_device_command_query_date_time
;
794 modem
->device
->set_date_time
= &gsmd_device_command_set_date_time
;
795 modem
->device
->get_info
= &gsmd_device_command_get_info
;
796 modem
->device
->set_antenna_power
= &gsmd_device_command_set_antenna_power
;
797 modem
->device
->get_antenna_power
= &gsmd_device_command_get_antenna_power
;
798 modem
->device
->get_features
= &gsmd_device_command_get_features
;