Hi Christophe,
All of the patch looks fine, except:
@@ -436,16 +458,36 @@ static void query_passwd_state_cb(struct qmi_result
*result,
{
struct cb_data *cbd = user_data;
ofono_sim_passwd_cb_t cb = cbd->cb;
+ struct ofono_sim *sim = cbd->user;
+ struct sim_data *data = ofono_sim_get_data(sim);
struct sim_status sim_stat;
-
- DBG("");
-
- if (!handle_get_card_status_result(result, &sim_stat)) {
+ enum get_card_status_result res;
+
+ res = handle_get_card_status_result(result, &sim_stat);
+ switch (res) {
+ case GET_CARD_STATUS_RESULT_OK:
+ DBG("passwd state %d", sim_stat.passwd_state);
+ data->retry_count = 0;
+ CALLBACK_WITH_SUCCESS(cb, sim_stat.passwd_state, cbd->data);
+ break;
+ case GET_CARD_STATUS_RESULT_TEMP_ERROR:
+ data->retry_count++;
+ if (data->retry_count > MAX_RETRY_COUNT) {
+ DBG("Failed after %d attempts", data->retry_count);
+ data->retry_count = 0;
+ CALLBACK_WITH_FAILURE(cb, -1, cbd->data);
+ } else {
+ usleep(20000);
You cannot use usleep here. usleep blocks, so the rest of the daemon is
unable to process anything else. So for example, if you have multiple
modems, usleep would block oFono from receiving / sending any events to
these, D-Bus API would be blocked, etc.
For an example of how to get around this using GLib timers, see
drivers/atmodem/atutil.c.
The at_util_sim_state_query (at_util_sim_state_query_new()) is doing
something extremely similar to what you're trying to do here.
Regards,
-Denis
_______________________________________________
ofono mailing list
[email protected]
https://lists.ofono.org/mailman/listinfo/ofono