diff --git a/src/shared/hfp.c b/src/shared/hfp.c
index d01915a..f94df90 100644
--- a/src/shared/hfp.c
+++ b/src/shared/hfp.c
set_indicator_value(index, val, hfp->ag_ind, hfp);
}
-static void slc_cmer_resp(enum hfp_result result, enum hfp_error cme_err,
+static void cops_cb(struct hfp_context *context, void *user_data)
+{
+ struct hfp_hf *hfp = user_data;
+ unsigned int mode, val;
+ char name[255];
+
+ DBG(hfp, "");
+
+ if (!hfp_context_get_number(context, &mode))
+ return;
+
+ if (!hfp_context_get_number(context, &val))
+ return;
+
+ if (!hfp_context_get_string(context, name, sizeof(name))) {
+ DBG(hfp, "hf: Could not get string");
+ return;
+ }
+
+ if (hfp->callbacks && hfp->callbacks->update_operator)
+ hfp->callbacks->update_operator(name, hfp->callbacks_data);
+}
+
+static void cops_resp(enum hfp_result result, enum hfp_error cme_err,
void *user_data)
{
struct hfp_hf *hfp = user_data;
DBG(hfp, "");
if (result != HFP_RESULT_OK) {
- DBG(hfp, "hf: CMER error: %d", result);
+ DBG(hfp, "hf: COPS? error: %d", result);
goto failed;
}
hfp->callbacks->session_ready(HFP_RESULT_OK, 0,
hfp->callbacks_data);
+ return;
+
+failed:
+ if (hfp->callbacks->session_ready)
+ hfp->callbacks->session_ready(result, cme_err,
+ hfp->callbacks_data);
+}
+
+static void cops_conf_resp(enum hfp_result result, enum hfp_error cme_err,
+ void *user_data)
+{
+ struct hfp_hf *hfp = user_data;
+
+ DBG(hfp, "");
+
+ if (result != HFP_RESULT_OK) {
+ DBG(hfp, "hf: COPS= error: %d", result);
+ goto failed;
+ }
+
+ /* SLC creation done, continue with default setup */
+ if (!hfp_hf_send_command(hfp, cops_resp, hfp,
+ "AT+COPS?")) {
+ DBG(hfp, "hf: Could not send AT+COPS?");
+ result = HFP_RESULT_ERROR;
+ goto failed;
+ }
+
+ return;
+
+failed:
+ if (hfp->callbacks->session_ready)
+ hfp->callbacks->session_ready(result, cme_err,
+ hfp->callbacks_data);
+}
+
+static void slc_cmer_resp(enum hfp_result result, enum hfp_error cme_err,
+ void *user_data)
+{
+ struct hfp_hf *hfp = user_data;
+
+ DBG(hfp, "");
+
+ if (result != HFP_RESULT_OK) {
+ DBG(hfp, "hf: CMER error: %d", result);
+ goto failed;
+ }
+
+ /* SLC creation done, continue with default setup */
+ if (!hfp_hf_send_command(hfp, cops_conf_resp, hfp,
+ "AT+COPS=3,0")) {
+ DBG(hfp, "hf: Could not send AT+COPS=3,0");
+ result = HFP_RESULT_ERROR;
+ goto failed;
+ }
+
/* Register unsolicited results handlers */
hfp_hf_register(hfp, ciev_cb, "+CIEV", hfp, NULL);
+ hfp_hf_register(hfp, cops_cb, "+COPS", hfp, NULL);
return;
diff --git a/src/shared/hfp.h b/src/shared/hfp.h
index e6f7bbb..27f6d2d 100644
--- a/src/shared/hfp.h
+++ b/src/shared/hfp.h
void *user_data);
void (*update_indicator)(enum hfp_indicator indicator, uint32_t val,
void *user_data);
+ void (*update_operator)(const char *operator_name, void *user_data);
};
struct hfp_hf *hfp_hf_new(int fd);
diff --git a/unit/test-hfp.c b/unit/test-hfp.c
index 371415a..2a85ec5 100644
--- a/unit/test-hfp.c
+++ b/unit/test-hfp.c
frg_pdu('0', ',', '0', ',', '0', ',', '0', ',', '5'), \
frg_pdu(',', '0', ',', '5', '\r', '\n'), \
frg_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \
- raw_pdu('\r', '\n', 'O', 'K', '\r', '\n')
+ raw_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \
+ raw_pdu('\r', '\n', 'O', 'K', '\r', '\n'), \
+ raw_pdu('\r', '\n', '+', 'C', 'O', 'P', 'S', ':', ' '), \
+ frg_pdu('0', ',', '0', ',', '\"', 'T', 'E', 'S', 'T'), \
+ frg_pdu('\"', '\r', '\n'), \
+ frg_pdu('\r', '\n', 'O', 'K', '\r', '\n')
static void hf_session_ready_cb(enum hfp_result res, enum hfp_error cme_err,
void *user_data)