Bluetooth: HFP_HF: Support unsolicited result code +CLIP
Handle the unsolicited result code +CLIP. Add a callback `clip` to notify the application if the configuration `CONFIG_BT_HFP_HF_CLI` is enabled. Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
This commit is contained in:
parent
e6d42cc37e
commit
8c61b9cea6
2 changed files with 43 additions and 1 deletions
|
@ -155,6 +155,19 @@ struct bt_hfp_hf_cb {
|
|||
*/
|
||||
void (*cmd_complete_cb)(struct bt_conn *conn,
|
||||
struct bt_hfp_hf_cmd_complete *cmd);
|
||||
/** HF calling line identification notification callback to application
|
||||
*
|
||||
* If this callback is provided it will be called whenever there
|
||||
* is a unsolicited result code +CLIP.
|
||||
* If @kconfig{CONFIG_BT_HFP_HF_CLI} is not enabled, the unsolicited
|
||||
* result code +CLIP will be ignored. And the callback will not be
|
||||
* notified.
|
||||
*
|
||||
* @param conn Connection object.
|
||||
* @param number Notified phone number.
|
||||
* @param type Specify the format of the phone number.
|
||||
*/
|
||||
void (*clip)(struct bt_conn *conn, char *number, uint8_t type);
|
||||
};
|
||||
|
||||
/** @brief Register HFP HF profile
|
||||
|
|
|
@ -431,13 +431,42 @@ int ring_handle(struct at_client *hf_at)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BT_HFP_HF_CLI)
|
||||
int clip_handle(struct at_client *hf_at)
|
||||
{
|
||||
struct bt_hfp_hf *hf = CONTAINER_OF(hf_at, struct bt_hfp_hf, at);
|
||||
struct bt_conn *conn = hf->acl;
|
||||
char *number;
|
||||
uint32_t type;
|
||||
int err;
|
||||
|
||||
number = at_get_string(hf_at);
|
||||
|
||||
err = at_get_number(hf_at, &type);
|
||||
if (err) {
|
||||
LOG_WRN("could not get the type");
|
||||
} else {
|
||||
type = 0;
|
||||
}
|
||||
|
||||
if (bt_hf->clip) {
|
||||
bt_hf->clip(conn, number, (uint8_t)type);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* CONFIG_BT_HFP_HF_CLI */
|
||||
|
||||
static const struct unsolicited {
|
||||
const char *cmd;
|
||||
enum at_cmd_type type;
|
||||
int (*func)(struct at_client *hf_at);
|
||||
} handlers[] = {
|
||||
{ "CIEV", AT_CMD_TYPE_UNSOLICITED, ciev_handle },
|
||||
{ "RING", AT_CMD_TYPE_OTHER, ring_handle }
|
||||
{ "RING", AT_CMD_TYPE_OTHER, ring_handle },
|
||||
#if defined(CONFIG_BT_HFP_HF_CLI)
|
||||
{ "CLIP", AT_CMD_TYPE_UNSOLICITED, clip_handle },
|
||||
#endif /* CONFIG_BT_HFP_HF_CLI */
|
||||
};
|
||||
|
||||
static const struct unsolicited *hfp_hf_unsol_lookup(struct at_client *hf_at)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue