1/* Copyright (C) 2007-2008 The Android Open Source Project
2**
3** This software is licensed under the terms of the GNU General Public
4** License version 2, as published by the Free Software Foundation, and
5** may be copied, distributed, and modified under those terms.
6**
7** This program is distributed in the hope that it will be useful,
8** but WITHOUT ANY WARRANTY; without even the implied warranty of
9** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10** GNU General Public License for more details.
11*/
12#ifndef _android_modem_h_
13#define _android_modem_h_
14
15#include "sim_card.h"
16#include "sms.h"
17
18/** MODEM OBJECT
19 **/
20typedef struct AModemRec_*    AModem;
21
22/* a function used by the modem to send unsolicited messages to the channel controller */
23typedef void (*AModemUnsolFunc)( void*  opaque, const char*  message );
24
25extern AModem      amodem_create( int  base_port, AModemUnsolFunc  unsol_func, void*  unsol_opaque );
26extern void        amodem_set_legacy( AModem  modem );
27extern void        amodem_destroy( AModem  modem );
28
29/* send a command to the modem */
30extern const char*  amodem_send( AModem  modem, const char*  cmd );
31
32/* simulate the receipt on an incoming SMS message */
33extern void         amodem_receive_sms( AModem  modem, SmsPDU  pdu );
34
35/** RADIO STATE
36 **/
37typedef enum {
38    A_RADIO_STATE_OFF = 0,          /* Radio explictly powered off (eg CFUN=0) */
39    A_RADIO_STATE_ON,               /* Radio on */
40} ARadioState;
41
42extern ARadioState  amodem_get_radio_state( AModem modem );
43extern void         amodem_set_radio_state( AModem modem, ARadioState  state );
44
45/** SIM CARD STATUS
46 **/
47extern ASimCard    amodem_get_sim( AModem  modem );
48
49/** VOICE AND DATA NETWORK REGISTRATION
50 **/
51
52/* 'stat' for +CREG/+CGREG commands */
53typedef enum {
54    A_REGISTRATION_UNREGISTERED = 0,
55    A_REGISTRATION_HOME = 1,
56    A_REGISTRATION_SEARCHING,
57    A_REGISTRATION_DENIED,
58    A_REGISTRATION_UNKNOWN,
59    A_REGISTRATION_ROAMING
60} ARegistrationState;
61
62typedef enum {
63    A_GPRS_NETWORK_UNKNOWN = 0,
64    A_GPRS_NETWORK_GPRS,
65    A_GPRS_NETWORK_EDGE,
66    A_GPRS_NETWORK_UMTS
67} AGprsNetworkType;
68
69extern ARegistrationState  amodem_get_voice_registration( AModem  modem );
70extern void                amodem_set_voice_registration( AModem  modem, ARegistrationState    state );
71
72extern ARegistrationState  amodem_get_data_registration( AModem  modem );
73extern void                amodem_set_data_registration( AModem  modem, ARegistrationState    state );
74extern void                amodem_set_data_network_type( AModem  modem, AGprsNetworkType   type );
75
76extern AGprsNetworkType    android_parse_network_type( const char*  speed );
77
78
79/** OPERATOR NAMES
80 **/
81typedef enum {
82    A_NAME_LONG = 0,
83    A_NAME_SHORT,
84    A_NAME_NUMERIC,
85    A_NAME_MAX  /* don't remove */
86} ANameIndex;
87
88/* retrieve operator name into user-provided buffer. returns number of writes written, including terminating zero */
89extern int   amodem_get_operator_name ( AModem  modem, ANameIndex  index, char*  buffer, int  buffer_size );
90
91/* reset one operator name from a user-provided buffer, set buffer_size to -1 for zero-terminated strings */
92extern void  amodem_set_operator_name( AModem  modem, ANameIndex  index, const char*  buffer, int  buffer_size );
93
94/** CALL STATES
95 **/
96
97typedef enum {
98    A_CALL_OUTBOUND = 0,
99    A_CALL_INBOUND  = 1,
100} ACallDir;
101
102typedef enum {
103    A_CALL_ACTIVE = 0,
104    A_CALL_HELD,
105    A_CALL_DIALING,
106    A_CALL_ALERTING,
107    A_CALL_INCOMING,
108    A_CALL_WAITING
109} ACallState;
110
111typedef enum {
112    A_CALL_VOICE = 0,
113    A_CALL_DATA,
114    A_CALL_FAX,
115    A_CALL_UNKNOWN = 9
116} ACallMode;
117
118#define  A_CALL_NUMBER_MAX_SIZE  16
119
120typedef struct {
121    int         id;
122    ACallDir    dir;
123    ACallState  state;
124    ACallMode   mode;
125    int         multi;
126    char        number[ A_CALL_NUMBER_MAX_SIZE+1 ];
127} ACallRec, *ACall;
128
129extern int    amodem_get_call_count( AModem  modem );
130extern ACall  amodem_get_call( AModem  modem,  int  index );
131extern ACall  amodem_find_call_by_number( AModem  modem, const char*  number );
132extern int    amodem_add_inbound_call( AModem  modem, const char*  number );
133extern int    amodem_update_call( AModem  modem, const char*  number, ACallState  state );
134extern int    amodem_disconnect_call( AModem  modem, const char*  number );
135
136/**/
137
138#endif /* _android_modem_h_ */
139