blob: cbe8f46f8e5b9048504c2f11cadd9279987aae7d [file] [log] [blame]
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -08001/* 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 );
David Turner6f290f22009-04-18 20:50:40 -070026extern void amodem_set_legacy( AModem modem );
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080027extern 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
Tim Baverstock4c6b10a2010-12-15 17:31:13 +000045/* Set the received signal strength indicator and bit error rate */
46extern void amodem_set_signal_strength( AModem modem, int rssi, int ber );
47
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080048/** SIM CARD STATUS
49 **/
50extern ASimCard amodem_get_sim( AModem modem );
51
52/** VOICE AND DATA NETWORK REGISTRATION
53 **/
54
55/* 'stat' for +CREG/+CGREG commands */
56typedef enum {
57 A_REGISTRATION_UNREGISTERED = 0,
58 A_REGISTRATION_HOME = 1,
59 A_REGISTRATION_SEARCHING,
60 A_REGISTRATION_DENIED,
61 A_REGISTRATION_UNKNOWN,
62 A_REGISTRATION_ROAMING
63} ARegistrationState;
64
65typedef enum {
Jaime Lopez1a000852010-07-21 18:03:58 -070066 A_DATA_NETWORK_UNKNOWN = 0,
67 A_DATA_NETWORK_GPRS,
68 A_DATA_NETWORK_EDGE,
69 A_DATA_NETWORK_UMTS,
70 A_DATA_NETWORK_LTE,
71 A_DATA_NETWORK_CDMA1X,
72 A_DATA_NETWORK_EVDO, // TODO: Should REV0, REVA and REVB be added?
73} ADataNetworkType;
74// TODO: Merge the usage of these two structs and rename ADataNetworkType
75typedef enum {
76 A_TECH_GSM = 0,
77 A_TECH_WCDMA,
78 A_TECH_CDMA,
79 A_TECH_EVDO,
80 A_TECH_LTE,
81 A_TECH_UNKNOWN // This must always be the last value in the enum
82} AModemTech;
83
84typedef enum {
85 A_SUBSCRIPTION_NVRAM = 0,
86 A_SUBSCRIPTION_RUIM,
87 A_SUBSCRIPTION_UNKNOWN // This must always be the last value in the enum
88} ACdmaSubscriptionSource;
89
90typedef enum {
91 A_ROAMING_PREF_HOME = 0,
92 A_ROAMING_PREF_AFFILIATED,
93 A_ROAMING_PREF_ANY,
94 A_ROAMING_PREF_UNKNOWN // This must always be the last value in the enum
95} ACdmaRoamingPref;
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -080096
97extern ARegistrationState amodem_get_voice_registration( AModem modem );
98extern void amodem_set_voice_registration( AModem modem, ARegistrationState state );
99
100extern ARegistrationState amodem_get_data_registration( AModem modem );
101extern void amodem_set_data_registration( AModem modem, ARegistrationState state );
Jaime Lopez1a000852010-07-21 18:03:58 -0700102extern void amodem_set_data_network_type( AModem modem, ADataNetworkType type );
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800103
Jaime Lopez1a000852010-07-21 18:03:58 -0700104extern ADataNetworkType android_parse_network_type( const char* speed );
105extern AModemTech android_parse_modem_tech( const char* tech );
106extern void amodem_set_cdma_subscription_source( AModem modem, ACdmaSubscriptionSource ssource );
107extern void amodem_set_cdma_prl_version( AModem modem, int prlVersion);
The Android Open Source Project8b23a6c2009-03-03 19:30:32 -0800108
109
110/** OPERATOR NAMES
111 **/
112typedef enum {
113 A_NAME_LONG = 0,
114 A_NAME_SHORT,
115 A_NAME_NUMERIC,
116 A_NAME_MAX /* don't remove */
117} ANameIndex;
118
119/* retrieve operator name into user-provided buffer. returns number of writes written, including terminating zero */
120extern int amodem_get_operator_name ( AModem modem, ANameIndex index, char* buffer, int buffer_size );
121
122/* reset one operator name from a user-provided buffer, set buffer_size to -1 for zero-terminated strings */
123extern void amodem_set_operator_name( AModem modem, ANameIndex index, const char* buffer, int buffer_size );
124
125/** CALL STATES
126 **/
127
128typedef enum {
129 A_CALL_OUTBOUND = 0,
130 A_CALL_INBOUND = 1,
131} ACallDir;
132
133typedef enum {
134 A_CALL_ACTIVE = 0,
135 A_CALL_HELD,
136 A_CALL_DIALING,
137 A_CALL_ALERTING,
138 A_CALL_INCOMING,
139 A_CALL_WAITING
140} ACallState;
141
142typedef enum {
143 A_CALL_VOICE = 0,
144 A_CALL_DATA,
145 A_CALL_FAX,
146 A_CALL_UNKNOWN = 9
147} ACallMode;
148
149#define A_CALL_NUMBER_MAX_SIZE 16
150
151typedef struct {
152 int id;
153 ACallDir dir;
154 ACallState state;
155 ACallMode mode;
156 int multi;
157 char number[ A_CALL_NUMBER_MAX_SIZE+1 ];
158} ACallRec, *ACall;
159
160extern int amodem_get_call_count( AModem modem );
161extern ACall amodem_get_call( AModem modem, int index );
162extern ACall amodem_find_call_by_number( AModem modem, const char* number );
163extern int amodem_add_inbound_call( AModem modem, const char* number );
164extern int amodem_update_call( AModem modem, const char* number, ACallState state );
165extern int amodem_disconnect_call( AModem modem, const char* number );
166
167/**/
168
169#endif /* _android_modem_h_ */