libcom3.h
Last updated: 07-Apr-2025
Go to the documentation of this file.
1Â #pragma once 2Â 3Â #if defined __GNUC__ && defined VFI_COM_SHARED_EXPORT 4Â #define COM3_DllSpec __attribute__((visibility("default"))) 5Â #else 6Â #define COM3_DllSpec // used for both, static libraries and program symbol import 7Â #endif 8Â 9Â #include <sys/types.h> 10Â #include <ipc/jsobject.h> 11Â #include <exception> 12Â 13Â namespace vficom { 14Â 15Â namespace cmd { 16Â 17Â COM3_DllSpec extern const char ping[]; 18Â COM3_DllSpec extern const char stk_on[]; 19Â COM3_DllSpec extern const char stk_off[]; 20Â COM3_DllSpec extern const char stk_status[]; 21Â COM3_DllSpec extern const char stk_write[]; 22Â COM3_DllSpec extern const char ussd_status[]; 23Â COM3_DllSpec extern const char ussd_write[]; 24Â COM3_DllSpec extern const char sim_access[]; 25Â COM3_DllSpec extern const char wlan_scan[]; 26Â 27Â } // namespace cmd 28Â 29Â namespace cmdparam { 30Â 31Â namespace in { 32Â 33Â COM3_DllSpec extern const char command[]; 34Â 35Â namespace stk_on { 36Â 37Â COM3_DllSpec extern const char timeout[]; 38Â 39Â } // namespace stk_on 40Â 41Â namespace stk_off { 42Â 43Â COM3_DllSpec extern const char timeout[]; 44Â 45Â } // namespace stk_off 46Â 47Â namespace stk_status { 48Â 49Â COM3_DllSpec extern const char timeout[]; 50Â 51Â } // namespace stk_status 52Â 53Â namespace stk_write { 54Â 55Â COM3_DllSpec extern const char timeout[]; 56Â COM3_DllSpec extern const char message_obj[]; 57Â 58Â namespace msg { 59Â 60Â enum STKTRCommand { 61Â STK_TR_CMD_REFRESH = 1, 62Â STK_TR_CMD_SETUP_EVENT_LIST = 5, 63Â STK_TR_CMD_SELECT_ITEM = 36, 64Â STK_TR_CMD_SETUP_MENU = 37, 65Â STK_TR_MAX_ENUM = 0x7FFFFFFF 66Â }; 67Â 68Â enum STKENVCommand { 69Â STK_ENV_CMD_MENU_SELECT = 211, 70Â STK_ENV_CMD_EVENT_DOWNLOAD = 214, 71Â STK_ENV_MAX_ENUM = 0x7FFFFFFF 72Â }; 73Â 74Â COM3_DllSpec extern const char usat_command[]; 75Â COM3_DllSpec extern const char proactCmd[]; 76Â COM3_DllSpec extern const char envCmd[]; 77Â COM3_DllSpec extern const char parameters[]; 78Â 79Â namespace tr { 80Â 81Â namespace refresh { 82Â 83Â COM3_DllSpec extern const char result[]; 84Â 85Â } // namespace refresh 86Â 87Â namespace setup_event_list { 88Â 89Â COM3_DllSpec extern const char result[]; 90Â 91Â } // namespace setup_event_list 92Â 93Â namespace select_item { 94Â 95Â COM3_DllSpec extern const char result[]; 96Â COM3_DllSpec extern const char add_result[]; 97Â COM3_DllSpec extern const char dcs[]; 98Â COM3_DllSpec extern const char hex_string[]; 99Â 100Â } // namespace select_item 101Â 102Â namespace setup_menu { 103Â 104Â COM3_DllSpec extern const char result[]; 105Â 106Â } // namespace setup_menu 107Â 108Â } // namespace tr 109Â 110Â namespace env { 111Â 112Â namespace menu_select { 113Â 114Â COM3_DllSpec extern const char item_id[]; 115Â 116Â } // namespace menu_select 117Â 118Â namespace event_download { 119Â 120Â COM3_DllSpec extern const char event[]; 121Â 122Â } // namespace event_download 123Â 124Â } // namespace env 125Â 126Â } // namespace msg 127Â 128Â } // namespace stk_write 129Â 130Â namespace ussd_write { 131Â 132Â COM3_DllSpec extern const char n[]; 133Â COM3_DllSpec extern const char str[]; 134Â COM3_DllSpec extern const char dcs[]; 135Â COM3_DllSpec extern const char timeout[]; 136Â 137Â } // namespace ussd_write 138Â 139Â namespace ussd_status { 140Â 141Â COM3_DllSpec extern const char timeout[]; 142Â 143Â } // namespace ussd_status 144Â 145Â namespace sim_access { 146Â 147Â COM3_DllSpec extern const char timeout[]; 148Â COM3_DllSpec extern const char json_cmd[]; 149Â 150Â } // namespace sim_access 151Â 152Â namespace ping { 153Â 154Â /* Input parameters */ 155Â COM3_DllSpec extern const char destination[]; 156Â COM3_DllSpec extern const char count[]; 157Â COM3_DllSpec extern const char timeout[]; 158Â COM3_DllSpec extern const char addr_family[]; 159Â COM3_DllSpec extern const char dont_fragment[]; 160Â COM3_DllSpec extern const char interface[]; 161Â COM3_DllSpec extern const char interval[]; 162Â COM3_DllSpec extern const char size[]; 163Â COM3_DllSpec extern const char waittime[]; 164Â 165Â } // namespace ping 166Â 167Â } // namespace in 168Â 169Â namespace out { 170Â 171Â COM3_DllSpec extern const char comerr[]; 172Â 173Â namespace ping { 174Â 175Â /* Output parameters */ 176Â COM3_DllSpec extern const char transmitted[]; 177Â COM3_DllSpec extern const char received[]; 178Â COM3_DllSpec extern const char rtt_avg[]; 179Â COM3_DllSpec extern const char rtt_min[]; 180Â COM3_DllSpec extern const char rtt_max[]; 181Â 182Â } // namespace ping 183Â 184Â namespace stk_status { 185Â 186Â COM3_DllSpec extern const char status[]; 187Â 188Â } // namespace stk_status 189Â 190Â namespace ussd_status { 191Â 192Â COM3_DllSpec extern const char status[]; 193Â 194Â } // namespace ussd_status 195Â 196Â namespace sim_access { 197Â 198Â COM3_DllSpec extern const char json_resp[]; 199Â 200Â } // namespace sim_access 201Â 202Â namespace wlan_scan { 203Â 204Â COM3_DllSpec extern const char json_resp[]; 205Â 206Â namespace json_keys { 207Â 208Â // Keys of the JSON array returned by wlan_scan 209Â COM3_DllSpec extern const char ssid[]; //<! String, can be empty 210Â COM3_DllSpec extern const char bssid[]; 211Â COM3_DllSpec extern const char adhoc[]; 212Â COM3_DllSpec extern const char pairw[]; 213Â COM3_DllSpec extern const char group[]; 214Â COM3_DllSpec extern const char km[]; 215Â COM3_DllSpec extern const char perc[]; 216Â COM3_DllSpec extern const char dbm[]; 217Â COM3_DllSpec extern const char freq[]; 218Â COM3_DllSpec extern const char proto[]; 219Â COM3_DllSpec extern const char std[]; 220Â 221Â } // namespace json_keys 222Â 223Â } // namespace wlan_scan 224Â 225Â } // namespace out 226Â 227Â } // namespace cmdparam 228Â 229Â namespace event { 230Â enum EventType { 231Â EVT_URC_STK = 0, 232Â EVT_URC_USSD = 1, 233Â EVT_MAX_ENUM = 0x7FFFFFFF 234Â }; 235Â 236Â namespace stk { 237Â enum STKURCProCommand { 238Â SET_UP_EVENT_LIST = 5, 239Â SELECT_ITEM = 36, 240Â MENU_SELECTION = 37, 241Â STK_URC_PRO_MAX_ENUM = 0x7FFFFFFF 242Â }; 243Â 244Â COM3_DllSpec extern const char urc[]; 245Â COM3_DllSpec extern const char proactive_command[]; 246Â COM3_DllSpec extern const char parameters[]; 247Â COM3_DllSpec extern const char timeout[]; 248Â 249Â namespace set_up_event_list { 250Â 251Â COM3_DllSpec extern const char event_list[]; 252Â 253Â } // namespace set_up_event_list 254Â 255Â namespace select_item { 256Â 257Â COM3_DllSpec extern const char cmd_qualifier[]; 258Â COM3_DllSpec extern const char alpha[]; 259Â COM3_DllSpec extern const char item_id[]; 260Â COM3_DllSpec extern const char total_items[]; 261Â COM3_DllSpec extern const char item_text[]; 262Â COM3_DllSpec extern const char next_action[]; 263Â COM3_DllSpec extern const char default_item[]; 264Â COM3_DllSpec extern const char icon_id[]; 265Â COM3_DllSpec extern const char icon_id_list_elem[]; 266Â 267Â } // namespace select_item 268Â 269Â namespace menu_selection { 270Â 271Â COM3_DllSpec extern const char cmd_qualifier[]; 272Â COM3_DllSpec extern const char alpha[]; 273Â COM3_DllSpec extern const char item_id[]; 274Â COM3_DllSpec extern const char total_items[]; 275Â COM3_DllSpec extern const char item_text[]; 276Â COM3_DllSpec extern const char next_action[]; 277Â COM3_DllSpec extern const char icon_id[]; 278Â COM3_DllSpec extern const char icon_id_list_elem[]; 279Â 280Â } // namespace menu_selection 281Â 282Â } // namespace stk 283Â 284Â namespace ussd { 285Â 286Â // Names correspond to 3GPP TS 27.00, Chapter 7.15, Unstructured supplementary service data +CUSD 287Â COM3_DllSpec extern const char m[]; 288Â COM3_DllSpec extern const char str[]; 289Â COM3_DllSpec extern const char dcs[]; 290Â 291Â } // namespace ussd 292Â 293Â } // namespace event 294Â 295Â namespace status { 296Â 297Â enum PipeStatus { 298Â OK = 0, 299Â INVALID = 1, 300Â NOSUPPORT = 2, 301Â NOTREADY = 3, 302Â FAILED = 5, 303Â TIMEOUT = 6, 304Â STARVATION = 7, 305Â USER_INTERRUPT = 8, 306Â MAX_ENUM = 0x7FFFFFFF 307Â }; 308Â 309Â } // namespace status 310Â 315Â class COM3_DllSpec Exception : std::exception { 316Â char description[64]; 317Â status::PipeStatus error; 318Â 319Â public: 320Â Exception(enum status::PipeStatus error, const char *description); 321Â 322Â virtual const char *what() const throw(); 323Â status::PipeStatus getError() const; 324Â }; 325Â 326Â class COM3_DllSpec Milliseconds { 327Â public: 328Â u_int64_t millis; 329Â 330Â Milliseconds(u_int32_t millis); 331Â ~Milliseconds(); 332Â }; 333Â 334Â class COM3_DllSpec CommandPipe { 335Â class ComdaemonPipe *impl; 336Â 337Â // Copy not valid 338Â CommandPipe(const CommandPipe &commandPipe); 339Â void operator=(const CommandPipe &commandPipe); 340Â 341Â public: 342Â CommandPipe(); 343Â virtual ~CommandPipe(); 344Â 354Â enum status::PipeStatus sendRecv(const vfiipc::JSObject &in, vfiipc::JSObject &out, Milliseconds millis); 355Â 367Â enum status::PipeStatus sendRecv(const vfiipc::JSObject &in, vfiipc::JSObject &out, Milliseconds millis, int interruptFD); 368Â }; 369Â 370Â class COM3_DllSpec EventPipe { 371Â class ComdaemonPipe *impl; 372Â 373Â public: 374Â EventPipe(event::EventType type); 375Â ~EventPipe(); 376Â 377Â // Copy not valid 378Â EventPipe(const EventPipe &eventPipe); 379Â void operator=(const EventPipe &eventPipe); 380Â 389Â enum status::PipeStatus recv(vfiipc::JSObject &out, Milliseconds millis); 390Â 401Â enum status::PipeStatus recv(vfiipc::JSObject &out, Milliseconds millis, int interruptFD); 402Â }; 403Â 404Â } // namespace vficom 405Â 406Â #undef COM3_DllSpec
Rate this article: