static void telit_gps_enable_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; ofono_location_reporting_enable_cb_t cb = cbd->cb; struct ofono_location_reporting *lr = cbd->user; struct gps_data *gd = ofono_location_reporting_get_data(lr); struct ofono_error error; DBG("lr=%p ok=%d", lr, ok); decode_at_error(&error, g_at_result_final_response(result)); if (!ok) { cb(&error, -1, cbd->data); g_free(cbd); return; } if (g_at_chat_send(gd->chat, "AT$GPSNMUN=1,0,0,0,0,0,0", none_prefix, telit_gps_ctl_cb, cbd, g_free) > 0) return; CALLBACK_WITH_FAILURE(cb, -1, cbd->data); g_free(cbd); }
static void telit_location_reporting_remove(struct ofono_location_reporting *lr) { struct gps_data *gd = ofono_location_reporting_get_data(lr); ofono_location_reporting_set_data(lr, NULL); g_at_chat_unref(gd->chat); g_free(gd); }
static void telit_portcfg_check_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; ofono_location_reporting_enable_cb_t cb = cbd->cb; struct ofono_location_reporting *lr = cbd->user; struct gps_data *gd = ofono_location_reporting_get_data(lr); struct ofono_error error; int requested_portcfg, current_portcfg; GAtResultIter iter; DBG("lr=%p ok=%d", lr, ok); decode_at_error(&error, g_at_result_final_response(result)); if (!ok) { cb(&error, -1, cbd->data); g_free(cbd); return; } g_at_result_iter_init(&iter, result); if (!g_at_result_iter_next(&iter, "#PORTCFG:")) goto fail; if (!g_at_result_iter_next_number(&iter, &requested_portcfg)) goto fail; if (!g_at_result_iter_next_number(&iter, ¤t_portcfg)) goto fail; if (current_portcfg != 8) { ofono_warn("Unable to start GPS, modem configuration invalid"); ofono_warn("Refer to doc/telit-modem.txt section HE910/GPS"); goto fail; } if (g_at_chat_send(gd->chat, "AT$GPSP=1", none_prefix, telit_gps_enable_cb, cbd, NULL) > 0) return; fail: CALLBACK_WITH_FAILURE(cb, -1, cbd->data); g_free(cbd); }
static void telit_location_reporting_enable(struct ofono_location_reporting *lr, ofono_location_reporting_enable_cb_t cb, void *data) { struct gps_data *gd = ofono_location_reporting_get_data(lr); struct cb_data *cbd = cb_data_new(cb, data); DBG("lr=%p", lr); cbd->user = lr; if (g_at_chat_send(gd->chat, "AT#PORTCFG?", portcfg_prefix, telit_portcfg_check_cb, cbd, NULL) > 0) return; CALLBACK_WITH_FAILURE(cb, -1, cbd->data); g_free(cbd); }
static void mbm_location_reporting_disable(struct ofono_location_reporting *lr, ofono_location_reporting_disable_cb_t cb, void *data) { struct gps_data *gd = ofono_location_reporting_get_data(lr); struct cb_data *cbd = cb_data_new(cb, data); DBG("lr=%p", lr); cbd->user = lr; if (g_at_chat_send(gd->chat, "AT*E2GPSCTL=0,5,1", none_prefix, mbm_e2gpsctl_disable_cb, cbd, g_free) > 0) return; CALLBACK_WITH_FAILURE(cb, data); g_free(cbd); }
static void mbm_e2gpsctl_disable_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; struct ofono_location_reporting *lr = cbd->user; ofono_location_reporting_disable_cb_t cb = cbd->cb; struct gps_data *gd = ofono_location_reporting_get_data(lr); DBG("lr=%p, ok=%d", lr, ok); if (!ok) { struct ofono_error error; decode_at_error(&error, g_at_result_final_response(result)); cb(&error, cbd->data); return; } g_at_chat_unref(gd->data_chat); CALLBACK_WITH_SUCCESS(cb, cbd->data); }