Hi Denis,
On 04/17/2017 07:37 PM, Denis Kenzior wrote:
Hi Jonas,
-static bool extract_ss_info(struct qmi_result *result, int *status)
+static int rat_to_tech(uint8_t rat)
+{
+ switch (rat) {
+ case QMI_NAS_NETWORK_RAT_GSM:
+ return ACCESS_TECHNOLOGY_GSM;
+ case QMI_NAS_NETWORK_RAT_UMTS:
+ return ACCESS_TECHNOLOGY_UTRAN;
+ case QMI_NAS_NETWORK_RAT_LTE:
+ return ACCESS_TECHNOLOGY_EUTRAN;
+ }
+
+ return -1;
+}
+
You might want to put this into drivers/qmimodem/nas.c as:
qmi_nas_rat_to_tech() and use it from both the netreg and gprs drivers
Good idea... will do!
-static void ss_info_notify(struct qmi_result *result, void *user_data)
+/*
+ * This method handles both Serving System Info requests and
+ * notifications. The presence of a callback differentiates between
+ * the two and the result is handled slightly differently accordingly.
+ * If there's a callback, we invoke it; otherwise we send a
notification
+ * to ofono about relevant state changes.
+ */
No, please don't do this, the notification callback and the query
callback should be different functions. If you need to perform some
common operations, then just extract those into a common function and
call it from both.
drivers/rilmodem/gprs-context.c, as one example, uses this pattern.
Personally, I find it rather elegant!
CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
@@ -163,6 +225,7 @@ static void create_nas_cb(struct qmi_service
*service, void *user_data)
{
struct ofono_gprs *gprs = user_data;
struct gprs_data *data = ofono_gprs_get_data(gprs);
+ struct cb_data *cbd;
DBG("");
@@ -178,11 +241,15 @@ static void create_nas_cb(struct qmi_service
*service, void *user_data)
* First get the SS info - the modem may already be connected,
* and the state-change notification may never arrive
*/
+ cbd = cb_data_new(NULL, NULL);
+ cbd->user = gprs;
qmi_service_send(data->nas, QMI_NAS_GET_SS_INFO, NULL,
- ss_info_notify, gprs, NULL);
+ handle_ss_info, cbd, g_free);
+ cbd = cb_data_new(NULL, NULL);
+ cbd->user = gprs;
qmi_service_register(data->nas, QMI_NAS_SS_INFO_IND,
- ss_info_notify, gprs, NULL);
+ handle_ss_info, cbd, g_free);
No, the original form was completely fine.
handle_ss_info takes a cbd user_data argument, not a gprs argument. But
if handle_ss_info is not acceptable, then I guess the above is fine.
/Jonas
_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono