static void at_cmgl_done(struct ofono_sms *sms) { struct sms_data *data = ofono_sms_get_data(sms); DBG(""); if (data->incoming == AT_UTIL_SMS_STORE_MT && data->store == AT_UTIL_SMS_STORE_ME) { at_cmgl_set_cpms(sms, AT_UTIL_SMS_STORE_SM); return; } g_at_chat_register(data->chat, "+CMTI:", at_cmti_notify, FALSE, sms, NULL); g_at_chat_register(data->chat, "+CMT:", at_cmt_notify, TRUE, sms, NULL); g_at_chat_register(data->chat, "+CDS:", at_cds_notify, TRUE, sms, NULL); g_at_chat_register(data->chat, "+CDSI:", at_cdsi_notify, FALSE, sms, NULL); /* We treat CMGR just like a notification */ g_at_chat_register(data->chat, "+CMGR:", at_cmgr_notify, TRUE, sms, NULL); }
static int mbm_enable(struct connman_device *device) { struct mbm_data *data = connman_device_get_data(device); const char *devnode; GIOChannel *channel; struct termios ti; int fd, index; _DBG_MBM("device %p", device); devnode = connman_device_get_control(device); if (devnode == NULL) return -EIO; fd = open(devnode, O_RDWR | O_NOCTTY); if (fd < 0) return -ENODEV; tcflush(fd, TCIOFLUSH); /* Switch TTY to raw mode */ memset(&ti, 0, sizeof(ti)); cfmakeraw(&ti); tcsetattr(fd, TCSANOW, &ti); channel = g_io_channel_unix_new(fd); if (channel == NULL) { close(fd); return -ENOMEM; } data->chat = g_at_chat_new(channel, 0); if (data->chat == NULL) return -EIO; g_io_channel_unref(channel); g_at_chat_register(data->chat, "*EMRDY:", notify_callback, FALSE, NULL, NULL); g_at_chat_register(data->chat, "*EMWI:", notify_callback, FALSE, NULL, NULL); g_at_chat_register(data->chat, "+PACSP", notify_callback, FALSE, NULL, NULL); index = connman_device_get_index(device); connman_inet_ifup(index); g_at_chat_send(data->chat, "AT&F E0 V1 X4 &C1 +CMEE=1", NULL, generic_callback, NULL, NULL); g_at_chat_send(data->chat, "AT+CFUN?", cfun_prefix, cfun_callback, device, NULL); g_at_chat_send(data->chat, "AT+CFUN=1", NULL, cfun_callback, device, NULL); return -EINPROGRESS; }
static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_gprs *gprs = user_data; struct gprs_data *gd = ofono_gprs_get_data(gprs); g_at_chat_register(gd->chat, "+CGEV:", cgev_notify, FALSE, gprs, NULL); g_at_chat_register(gd->chat, "+CGREG:", cgreg_notify, FALSE, gprs, NULL); ofono_gprs_register(gprs); }
static void at_ssn_initialized(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_ssn *ssn = user_data; GAtChat *chat = ofono_ssn_get_data(ssn); g_at_chat_register(chat, "+CSSI:", cssi_notify, FALSE, ssn, NULL); g_at_chat_register(chat, "+CSSU:", cssu_notify, FALSE, ssn, NULL); ofono_ssn_register(ssn); }
static void cvoice_support_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_audio_settings *as = user_data; struct audio_settings_data *asd = ofono_audio_settings_get_data(as); if (!ok) return; g_at_chat_register(asd->chat, "+CRING:", cring_notify, FALSE, as, NULL); g_at_chat_register(asd->chat, "^ORIG:", orig_notify, FALSE, as, NULL); g_at_chat_register(asd->chat, "^CEND:", cend_notify, FALSE, as, NULL); ofono_audio_settings_register(as); }
static void hfp_call_volume_initialized(gpointer user_data) { struct ofono_call_volume *cv = user_data; struct cv_data *vd = ofono_call_volume_get_data(cv); DBG(""); g_at_chat_register(vd->chat, "+VGS:", vgs_notify, FALSE, cv, NULL); g_at_chat_register(vd->chat, "+VGM:", vgm_notify, FALSE, cv, NULL); ofono_call_volume_register(cv); /* set sp and mic volume at 50 percents by default */ hfp_speaker_volume(cv, 50, sync_speaker_volume_cb, cv); hfp_microphone_volume(cv, 50, sync_microphone_volume_cb, cv); }
static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_modem *modem = user_data; struct telit_data *data = ofono_modem_get_data(modem); DBG("%p", modem); if (!ok) { g_at_chat_unref(data->chat); data->chat = NULL; ofono_modem_set_powered(modem, FALSE); return; } ofono_modem_set_powered(modem, TRUE); /* Enable sim state notification */ g_at_chat_send(data->chat, "AT#QSS=1", none_prefix, NULL, NULL, NULL); /* Follow sim state */ g_at_chat_register(data->chat, "#QSS:", telit_qss_notify, FALSE, modem, NULL); /* Query current sim state */ g_at_chat_send(data->chat, "AT#QSS?", qss_prefix, telit_qss_cb, modem, NULL); }
static int at_gprs_context_probe(struct ofono_gprs_context *gc, unsigned int vendor, void *data) { GAtChat *chat = data; struct gprs_context_data *gcd; struct stat st; DBG(""); if (stat(TUN_SYSFS_DIR, &st) < 0) { ofono_error("Missing support for TUN/TAP devices"); return -ENODEV; } gcd = g_try_new0(struct gprs_context_data, 1); if (gcd == NULL) return -ENOMEM; gcd->chat = g_at_chat_clone(chat); gcd->vendor = vendor; ofono_gprs_context_set_data(gc, gcd); chat = g_at_chat_get_slave(gcd->chat); if (chat == NULL) return 0; g_at_chat_register(chat, "+CGEV:", cgev_notify, FALSE, gc, NULL); return 0; }
static int telit_sap_enable(struct ofono_modem *modem, struct ofono_modem *sap_modem, int bt_fd) { struct telit_data *data = ofono_modem_get_data(modem); int fd; DBG("%p", modem); fd = telit_sap_open(); if (fd < 0) goto error; data->hw_io = g_io_channel_unix_new(fd); if (data->hw_io == NULL) { close(fd); goto error; } g_io_channel_set_encoding(data->hw_io, NULL, NULL); g_io_channel_set_buffered(data->hw_io, FALSE); g_io_channel_set_close_on_unref(data->hw_io, TRUE); data->bt_io = g_io_channel_unix_new(bt_fd); if (data->bt_io == NULL) goto error; g_io_channel_set_encoding(data->bt_io, NULL, NULL); g_io_channel_set_buffered(data->bt_io, FALSE); g_io_channel_set_close_on_unref(data->bt_io, TRUE); data->hw_watch = g_io_add_watch_full(data->hw_io, G_PRIORITY_DEFAULT, G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN, hw_event_cb, modem, hw_watch_remove); data->bt_watch = g_io_add_watch_full(data->bt_io, G_PRIORITY_DEFAULT, G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN, bt_event_cb, modem, bt_watch_remove); data->sap_modem = sap_modem; g_at_chat_register(data->chat, "#RSEN:", telit_rsen_notify, FALSE, modem, NULL); g_at_chat_send(data->chat, "AT#NOPT=0", NULL, NULL, NULL, NULL); /* Set SAP functionality */ g_at_chat_send(data->chat, "AT#RSEN=1,1,0,2,0", rsen_prefix, rsen_enable_cb, modem, NULL); return -EINPROGRESS; error: shutdown(bt_fd, SHUT_RDWR); close(bt_fd); sap_close_io(modem); return -EINVAL; }
static void mbm_e2nap_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_gprs_context *gc = user_data; struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); gcd->have_e2nap = ok; if (ok) g_at_chat_register(gcd->chat, "*E2NAP:", e2nap_notifier, FALSE, gc, NULL); }
static int hfp16_card_probe(struct ofono_handsfree_card *card, unsigned int vendor, void *data) { struct hfp *hfp = data; struct hfp_slc_info *info = &hfp->info; g_at_chat_register(info->chat, "+BCS:", bcs_notify, FALSE, hfp, NULL); return 0; }
static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_cdma_netreg *netreg = user_data; GAtChat *chat = ofono_cdma_netreg_get_data(netreg); if (!ok) { ofono_cdma_netreg_remove(netreg); return; } g_at_chat_register(chat, "^MODE:", mode_notify, FALSE, netreg, NULL); g_at_chat_register(chat, "^RSSILVL:", rssilvl_notify, FALSE, netreg, NULL); g_at_chat_register(chat, "^HRSSILVL:", hrssilvl_notify, FALSE, netreg, NULL); ofono_cdma_netreg_register(netreg); }
static void xgendata_query(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_modem *modem = user_data; struct ifx_data *data = ofono_modem_get_data(modem); GAtResultIter iter; const char *gendata; DBG(""); if (!ok) goto error; g_at_result_iter_init(&iter, result); if (!g_at_result_iter_next(&iter, "+XGENDATA:")) goto error; if (!g_at_result_iter_next_string(&iter, &gendata)) goto error; DBG("\n%s", gendata); /* switch to GSM character set instead of IRA */ g_at_chat_send(data->dlcs[AUX_DLC], "AT+CSCS=\"GSM\"", none_prefix, NULL, NULL, NULL); /* disable UART for power saving */ g_at_chat_send(data->dlcs[AUX_DLC], "AT+XPOW=0,0,0", none_prefix, NULL, NULL, NULL); data->have_sim = FALSE; /* notify that the modem is ready so that pre_sim gets called */ ofono_modem_set_powered(modem, TRUE); g_at_chat_register(data->dlcs[AUX_DLC], "+XSIM:", xsim_notify, FALSE, modem, NULL); /* enable XSIM and XLOCK notifications */ g_at_chat_send(data->dlcs[AUX_DLC], "AT+XSIMSTATE=1", none_prefix, NULL, NULL, NULL); g_at_chat_send(data->dlcs[AUX_DLC], "AT+XSIMSTATE?", xsimstate_prefix, xsimstate_query, modem, NULL); return; error: shutdown_device(data); ofono_modem_set_powered(modem, FALSE); }
static gboolean hfp_netreg_register(gpointer user_data) { struct ofono_netreg *netreg = user_data; struct netreg_data *nd = ofono_netreg_get_data(netreg); nd->register_source = 0; g_at_chat_register(nd->chat, "+CIEV:", ciev_notify, FALSE, netreg, NULL); ofono_netreg_register(netreg); return FALSE; }
static int hso_gprs_context_probe(struct ofono_gprs_context *gc, unsigned int vendor, void *data) { GAtChat *chat = data; struct gprs_context_data *gcd; gcd = g_new0(struct gprs_context_data, 1); gcd->chat = g_at_chat_clone(chat); g_at_chat_register(gcd->chat, "_OWANCALL:", owancall_notifier, FALSE, gc, NULL); ofono_gprs_context_set_data(gc, gcd); return 0; }
static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data) { g_print("PPP Link down: %d\n", reason); g_at_ppp_unref(ppp); ppp = NULL; if (option_modem == NULL) g_at_chat_set_debug(modem, gsmdial_debug, ""); else g_at_chat_set_debug(modem, gsmdial_debug, "Modem"); g_at_chat_register(modem, "NO CARRIER", no_carrier_notify, FALSE, NULL, NULL); g_at_chat_resume(modem); }
static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_modem *modem = user_data; struct he910_data *data = ofono_modem_get_data(modem); DBG("%p", modem); if (!ok) { g_at_chat_unref(data->chat); data->chat = NULL; g_at_chat_unref(data->modem); data->modem = NULL; ofono_modem_set_powered(modem, FALSE); return; } /* * Switch data carrier detect signal off. * When the DCD is disabled the modem does not hangup anymore * after the data connection. */ g_at_chat_send(data->chat, "AT&C0", NULL, NULL, NULL, NULL); data->have_sim = FALSE; data->sms_phonebook_added = FALSE; ofono_modem_set_powered(modem, TRUE); /* * Tell the modem not to automatically initiate auto-attach * proceedures on its own. */ g_at_chat_send(data->chat, "AT#AUTOATT=0", none_prefix, NULL, NULL, NULL); /* Follow sim state */ g_at_chat_register(data->chat, "#QSS:", he910_qss_notify, FALSE, modem, NULL); /* Enable sim state notification */ g_at_chat_send(data->chat, "AT#QSS=2", none_prefix, NULL, NULL, NULL); g_at_chat_send(data->chat, "AT#QSS?", qss_prefix, qss_query_cb, modem, NULL); }
static void gprs_initialized(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_gprs *gprs = user_data; struct gprs_data *gd = ofono_gprs_get_data(gprs); g_at_chat_register(gd->chat, "+CGEV:", cgev_notify, FALSE, gprs, NULL); g_at_chat_register(gd->chat, "+CGREG:", cgreg_notify, FALSE, gprs, NULL); switch (gd->vendor) { case OFONO_VENDOR_HUAWEI: g_at_chat_register(gd->chat, "^MODE:", huawei_mode_notify, FALSE, gprs, NULL); break; case OFONO_VENDOR_UBLOX: case OFONO_VENDOR_UBLOX_TOBY_L2: g_at_chat_register(gd->chat, "+UREG:", ublox_ureg_notify, FALSE, gprs, NULL); g_at_chat_send(gd->chat, "AT+UREG=1", none_prefix, NULL, NULL, NULL); break; case OFONO_VENDOR_TELIT: g_at_chat_register(gd->chat, "#PSNT:", telit_mode_notify, FALSE, gprs, NULL); g_at_chat_send(gd->chat, "AT#PSNT=1", none_prefix, NULL, NULL, NULL); default: g_at_chat_register(gd->chat, "+CPSB:", cpsb_notify, FALSE, gprs, NULL); g_at_chat_send(gd->chat, "AT+CPSB=1", none_prefix, NULL, NULL, NULL); break; } switch (gd->vendor) { case OFONO_VENDOR_IFX: /* Register for GPRS suspend notifications */ g_at_chat_register(gd->chat, "+XDATASTAT:", xdatastat_notify, FALSE, gprs, NULL); g_at_chat_send(gd->chat, "AT+XDATASTAT=1", none_prefix, NULL, NULL, NULL); break; } ofono_gprs_register(gprs); }
static void creg_cb(gboolean ok, GAtResult *result, gpointer user_data) { int status, lac, ci, tech; if (!ok) return; if (at_util_parse_reg(result, "+CREG:", NULL, &status, &lac, &ci, &tech) == FALSE) return; if (status != 1 && status != 5) { g_at_chat_register(control, "+CREG:", creg_notify, FALSE, NULL, NULL); return; } activate_gprs(status); }
static int ublox_gprs_context_probe(struct ofono_gprs_context *gc, unsigned int vendor, void *data) { GAtChat *chat = data; struct gprs_context_data *gcd; DBG(""); gcd = g_try_new0(struct gprs_context_data, 1); if (gcd == NULL) return -ENOMEM; gcd->chat = g_at_chat_clone(chat); ofono_gprs_context_set_data(gc, gcd); g_at_chat_register(chat, "+CGEV:", cgev_notify, FALSE, gc, NULL); return 0; }
static int hfp_netreg_probe(struct ofono_netreg *netreg, unsigned int vendor, void *user_data) { struct hfp_data *data = user_data; struct netreg_data *nd; nd = g_new0(struct netreg_data, 1); nd->chat = data->chat; memcpy(nd->cind_pos, data->cind_pos, HFP_INDICATOR_LAST); memcpy(nd->cind_val, data->cind_val, HFP_INDICATOR_LAST); ofono_netreg_set_data(netreg, nd); g_at_chat_register(nd->chat, "+CIEV:", ciev_notify, FALSE, netreg, NULL); g_idle_add(hfp_netreg_register, netreg); return 0; }
static void aplsiri_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_siri *siri = user_data; struct siri_data *sd = ofono_siri_get_data(siri); struct ofono_error error; GAtResultIter iter; gint value; if (!ok) goto fail; decode_at_error(&error, g_at_result_final_response(result)); if (error.type != OFONO_ERROR_TYPE_NO_ERROR) goto fail; g_at_result_iter_init(&iter, result); if (!g_at_result_iter_next(&iter, "+APLSIRI:")) goto fail; if (!g_at_result_iter_next_number(&iter, &value)) goto fail; if (value == 0) goto fail; g_at_chat_register(sd->chat, "+APLSIRI:", aplsiri_notify, FALSE, siri, NULL); ofono_siri_register(siri); ofono_siri_set_status(siri, value); return; fail: ofono_siri_remove(siri); }
static int ste_gprs_context_probe(struct ofono_gprs_context *gc, unsigned int vendor, void *data) { GAtChat *chat = data; struct gprs_context_data *gcd; struct conn_info *ci; int i; gcd = g_new0(struct gprs_context_data, 1); gcd->chat = chat; g_at_chat_register(gcd->chat, "+CGEV:", cgev_notify, FALSE, gc, NULL); ofono_gprs_context_set_data(gc, gcd); for (i = 0; i < MAX_CAIF_DEVICES; i++) { ci = conn_info_create(i, i+1); if (ci) g_caif_devices = g_slist_append(g_caif_devices, ci); } return 0; }
static int telit_sap_enable(struct ofono_modem *modem, struct ofono_modem *sap_modem, int bt_fd) { struct telit_data *data = ofono_modem_get_data(modem); int fd; DBG("%p", modem); fd = telit_sap_open(); if (fd < 0) goto error; data->hw_io = g_io_channel_unix_new(fd); if (data->hw_io == NULL) { close(fd); goto error; } g_io_channel_set_encoding(data->hw_io, NULL, NULL); g_io_channel_set_buffered(data->hw_io, FALSE); g_io_channel_set_close_on_unref(data->hw_io, TRUE); data->bt_io = g_io_channel_unix_new(bt_fd); if (data->bt_io == NULL) goto error; g_io_channel_set_encoding(data->bt_io, NULL, NULL); g_io_channel_set_buffered(data->bt_io, FALSE); g_io_channel_set_close_on_unref(data->bt_io, TRUE); // DBUS connection to smart card reader daemon connection = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); dbProxy = g_dbus_proxy_new_sync(connection, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.smart_e.RSAP","/RSAPServer","org.smart_e.RSAPServer", NULL, NULL); data->hw_watch = g_io_add_watch_full(data->hw_io, G_PRIORITY_DEFAULT, G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN, hw_event_cb, modem, hw_watch_remove); data->bt_watch = g_io_add_watch_full(data->bt_io, G_PRIORITY_DEFAULT, G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN, bt_event_cb, modem, bt_watch_remove); data->sap_modem = sap_modem; g_at_chat_register(data->chat, "#RSEN:", telit_rsen_notify, FALSE, modem, NULL); g_at_chat_send(data->chat, "AT#NOPT=0", NULL, NULL, NULL, NULL); /* Set SAP functionality */ g_at_chat_send(data->chat, "AT#RSEN=1,1,0,2,0", rsen_prefix, rsen_enable_cb, modem, NULL); return -EINPROGRESS; error: shutdown(bt_fd, SHUT_RDWR); close(bt_fd); sap_close_io(modem); return -EINVAL; }
static int phonesim_enable(struct ofono_modem *modem) { struct phonesim_data *data = ofono_modem_get_data(modem); GIOChannel *io; GAtSyntax *syntax; const char *address, *value; int sk, port; DBG("%p", modem); address = ofono_modem_get_string(modem, "Address"); if (address == NULL) return -EINVAL; port = ofono_modem_get_integer(modem, "Port"); if (port < 0) return -EINVAL; value = ofono_modem_get_string(modem, "Modem"); if (!g_strcmp0(value, "calypso")) data->calypso = TRUE; value = ofono_modem_get_string(modem, "Multiplexer"); if (!g_strcmp0(value, "internal")) data->use_mux = TRUE; sk = connect_socket(address, port); if (sk < 0) return sk; io = g_io_channel_unix_new(sk); if (io == NULL) { close(sk); return -ENOMEM; } if (data->calypso) syntax = g_at_syntax_new_gsm_permissive(); else syntax = g_at_syntax_new_gsmv1(); data->chat = g_at_chat_new(io, syntax); g_at_syntax_unref(syntax); g_io_channel_unref(io); if (data->chat == NULL) return -ENOMEM; if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(data->chat, phonesim_debug, ""); g_at_chat_set_disconnect_function(data->chat, phonesim_disconnected, modem); if (data->calypso) { g_at_chat_set_wakeup_command(data->chat, "AT\r", 500, 5000); g_at_chat_send(data->chat, "ATE0", NULL, NULL, NULL, NULL); g_at_chat_send(data->chat, "AT%CUNS=0", NULL, NULL, NULL, NULL); } if (data->use_mux) { g_at_chat_send(data->chat, "ATE0", NULL, NULL, NULL, NULL); g_at_mux_setup_gsm0710(data->chat, mux_setup, modem, NULL); g_at_chat_unref(data->chat); data->chat = NULL; return -EINPROGRESS; } g_at_chat_send(data->chat, "AT+CSCS=\"GSM\"", none_prefix, NULL, NULL, NULL); g_at_chat_register(data->chat, "+CRST:", crst_notify, FALSE, modem, NULL); g_at_chat_register(data->chat, "+CBC:", cbc_notify, FALSE, modem, NULL); g_at_chat_send(data->chat, "AT+CBC", none_prefix, NULL, NULL, NULL); data->hfp_watch = __ofono_modem_add_atom_watch(modem, OFONO_ATOM_TYPE_EMULATOR_HFP, emulator_hfp_watch, data, NULL); return 0; }
static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_netreg *netreg = user_data; struct netreg_data *nd = ofono_netreg_get_data(netreg); GAtResultIter iter; const char *str; int index; int min = 0; int max = 0; int tmp_min, tmp_max, invalid; if (!ok) goto error; g_at_result_iter_init(&iter, result); if (!g_at_result_iter_next(&iter, "+CIND:")) goto error; index = 1; /* * Telit encapsulates the CIND=? tokens with braces * so we need to skip them */ if (nd->vendor == OFONO_VENDOR_TELIT) g_at_result_iter_open_list(&iter); while (g_at_result_iter_open_list(&iter)) { /* Reset invalid default value for every token */ invalid = 99; if (!g_at_result_iter_next_string(&iter, &str)) goto error; if (!g_at_result_iter_open_list(&iter)) goto error; while (g_at_result_iter_next_range(&iter, &tmp_min, &tmp_max)) { if (tmp_min != tmp_max) { min = tmp_min; max = tmp_max; } else invalid = tmp_min; } if (!g_at_result_iter_close_list(&iter)) goto error; if (!g_at_result_iter_close_list(&iter)) goto error; if (g_str_equal("signal", str) == TRUE) { nd->signal_index = index; nd->signal_min = min; nd->signal_max = max; nd->signal_invalid = invalid; } index += 1; } if (nd->vendor == OFONO_VENDOR_TELIT) g_at_result_iter_close_list(&iter); if (nd->signal_index == 0) goto error; g_at_chat_send(nd->chat, "AT+CMER=3,0,0,1", NULL, NULL, NULL, NULL); g_at_chat_register(nd->chat, "+CIEV:", ciev_notify, FALSE, netreg, NULL); g_at_chat_register(nd->chat, "+CREG:", creg_notify, FALSE, netreg, NULL); ofono_netreg_register(netreg); return; error: ofono_error("This driver is not setup with Signal Strength reporting" " via CIND indications, please write proper netreg" " handling for this device"); ofono_netreg_remove(netreg); }
static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_netreg *netreg = user_data; struct netreg_data *nd = ofono_netreg_get_data(netreg); if (!ok) { ofono_error("Unable to initialize Network Registration"); ofono_netreg_remove(netreg); return; } switch (nd->vendor) { case OFONO_VENDOR_PHONESIM: g_at_chat_register(nd->chat, "+CSQ:", csq_notify, FALSE, netreg, NULL); break; case OFONO_VENDOR_CALYPSO: g_at_chat_send(nd->chat, "AT%CSQ=1", none_prefix, NULL, NULL, NULL); g_at_chat_register(nd->chat, "%CSQ:", calypso_csq_notify, FALSE, netreg, NULL); break; case OFONO_VENDOR_OPTION_HSO: g_at_chat_send(nd->chat, "AT_OSSYS=1", none_prefix, NULL, NULL, NULL); g_at_chat_send(nd->chat, "AT_OSQI=1", none_prefix, NULL, NULL, NULL); g_at_chat_register(nd->chat, "_OSIGQ:", option_osigq_notify, FALSE, netreg, NULL); g_at_chat_send(nd->chat, "AT_OSSYS?", none_prefix, NULL, NULL, NULL); g_at_chat_send(nd->chat, "AT_OSQI?", none_prefix, NULL, NULL, NULL); /* Register for network time update reports */ g_at_chat_register(nd->chat, "+CTZV:", ctzv_notify, FALSE, netreg, NULL); g_at_chat_send(nd->chat, "AT+CTZR=1", none_prefix, NULL, NULL, NULL); break; case OFONO_VENDOR_MBM: /* Enable network registration updates */ g_at_chat_send(nd->chat, "AT*E2REG=1", none_prefix, NULL, NULL, NULL); g_at_chat_send(nd->chat, "AT*EREG=2", none_prefix, NULL, NULL, NULL); g_at_chat_send(nd->chat, "AT*EPSB=1", none_prefix, NULL, NULL, NULL); /* Register for network technology updates */ g_at_chat_send(nd->chat, "AT*ERINFO=1", none_prefix, NULL, NULL, NULL); g_at_chat_register(nd->chat, "*ERINFO:", mbm_erinfo_notify, FALSE, netreg, NULL); /* Register for network time update reports */ g_at_chat_register(nd->chat, "*ETZV:", mbm_etzv_notify, FALSE, netreg, NULL); g_at_chat_send(nd->chat, "AT*ETZR=2", none_prefix, NULL, NULL, NULL); g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix, cind_support_cb, netreg, NULL); return; case OFONO_VENDOR_GOBI: /* * Gobi devices don't support unsolicited notifications * of technology changes, but register a handle for * CNTI so we get notified by any query. */ g_at_chat_register(nd->chat, "*CNTI:", gobi_cnti_notify, FALSE, netreg, NULL); break; case OFONO_VENDOR_NOVATEL: /* * Novatel doesn't support unsolicited notifications * of technology changes, but register a handle for * CNTI so we get notified by any query. */ g_at_chat_register(nd->chat, "$CNTI:", nw_cnti_notify, FALSE, netreg, NULL); break; case OFONO_VENDOR_HUAWEI: g_at_chat_register(nd->chat, "^RSSI:", huawei_rssi_notify, FALSE, netreg, NULL); break; case OFONO_VENDOR_IFX: /* Register for specific signal strength reports */ g_at_chat_register(nd->chat, "+XCIEV:", ifx_xciev_notify, FALSE, netreg, NULL); g_at_chat_send(nd->chat, "AT+XMER=1", none_prefix, NULL, NULL, NULL); /* Register for home zone reports */ g_at_chat_register(nd->chat, "+XHOMEZR:", ifx_xhomezr_notify, FALSE, netreg, NULL); g_at_chat_send(nd->chat, "AT+XHOMEZR=1", none_prefix, NULL, NULL, NULL); /* Register for network time update reports */ g_at_chat_register(nd->chat, "+CTZV:", ifx_ctzv_notify, FALSE, netreg, NULL); g_at_chat_register(nd->chat, "+CTZDST:", ifx_ctzdst_notify, FALSE, netreg, NULL); g_at_chat_send(nd->chat, "AT+CTZR=1", none_prefix, NULL, NULL, NULL); break; case OFONO_VENDOR_ZTE: case OFONO_VENDOR_NOKIA: /* Signal strength reporting via CIND is not supported */ break; default: g_at_chat_send(nd->chat, "AT+CIND=?", cind_prefix, cind_support_cb, netreg, NULL); return; } g_at_chat_register(nd->chat, "+CREG:", creg_notify, FALSE, netreg, NULL); ofono_netreg_register(netreg); }