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 **/ 20 typedef struct AModemRec_* AModem; 21 22 /* a function used by the modem to send unsolicited messages to the channel controller */ 23 typedef void (*AModemUnsolFunc)( void* opaque, const char* message ); 24 25 extern AModem amodem_create( int base_port, AModemUnsolFunc unsol_func, void* unsol_opaque ); 26 extern void amodem_set_legacy( AModem modem ); 27 extern void amodem_destroy( AModem modem ); 28 29 /* send a command to the modem */ 30 extern const char* amodem_send( AModem modem, const char* cmd ); 31 32 /* simulate the receipt on an incoming SMS message */ 33 extern void amodem_receive_sms( AModem modem, SmsPDU pdu ); 34 35 /** RADIO STATE 36 **/ 37 typedef enum { 38 A_RADIO_STATE_OFF = 0, /* Radio explictly powered off (eg CFUN=0) */ 39 A_RADIO_STATE_ON, /* Radio on */ 40 } ARadioState; 41 42 extern ARadioState amodem_get_radio_state( AModem modem ); 43 extern void amodem_set_radio_state( AModem modem, ARadioState state ); 44 45 /* Set the received signal strength indicator and bit error rate */ 46 extern void amodem_set_signal_strength( AModem modem, int rssi, int ber ); 47 48 /** SIM CARD STATUS 49 **/ 50 extern ASimCard amodem_get_sim( AModem modem ); 51 52 /** VOICE AND DATA NETWORK REGISTRATION 53 **/ 54 55 /* 'stat' for +CREG/+CGREG commands */ 56 typedef 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 65 typedef enum { 66 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 75 typedef 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 84 typedef 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 90 typedef 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; 96 97 extern ARegistrationState amodem_get_voice_registration( AModem modem ); 98 extern void amodem_set_voice_registration( AModem modem, ARegistrationState state ); 99 100 extern ARegistrationState amodem_get_data_registration( AModem modem ); 101 extern void amodem_set_data_registration( AModem modem, ARegistrationState state ); 102 extern void amodem_set_data_network_type( AModem modem, ADataNetworkType type ); 103 104 extern ADataNetworkType android_parse_network_type( const char* speed ); 105 extern AModemTech android_parse_modem_tech( const char* tech ); 106 extern void amodem_set_cdma_subscription_source( AModem modem, ACdmaSubscriptionSource ssource ); 107 extern void amodem_set_cdma_prl_version( AModem modem, int prlVersion); 108 109 110 /** OPERATOR NAMES 111 **/ 112 typedef 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 */ 120 extern 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 */ 123 extern void amodem_set_operator_name( AModem modem, ANameIndex index, const char* buffer, int buffer_size ); 124 125 /** CALL STATES 126 **/ 127 128 typedef enum { 129 A_CALL_OUTBOUND = 0, 130 A_CALL_INBOUND = 1, 131 } ACallDir; 132 133 typedef 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 142 typedef 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 151 typedef 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 160 extern int amodem_get_call_count( AModem modem ); 161 extern ACall amodem_get_call( AModem modem, int index ); 162 extern ACall amodem_find_call_by_number( AModem modem, const char* number ); 163 extern int amodem_add_inbound_call( AModem modem, const char* number ); 164 extern int amodem_update_call( AModem modem, const char* number, ACallState state ); 165 extern int amodem_disconnect_call( AModem modem, const char* number ); 166 167 /**/ 168 169 #endif /* _android_modem_h_ */ 170