{
GDBusConnection *conn;
gchar *ccwa;
- gchar number[BT_HF_CALLER_NUM_SIZE];
+ gchar *number;
+ gchar *ptr;
gchar *sep;
char fmt_str[BT_HF_FMT_STR_SIZE];
int len = strlen(buf);
if ((ccwa = strstr(buf, "\r\n+CCWA"))) {
snprintf(fmt_str, sizeof(fmt_str), "\r\n+CCWA: \"%%%ds",
- (int)(sizeof(number) - 1));
- if (sscanf(ccwa, fmt_str, number) == 1) {
+ BT_HF_CALLER_NUM_SIZE - 1);
+ if ((ptr = strstr(ccwa, "\"")) != NULL) {
+ number = ptr + 1;
sep = strchr(number, '"');
sep[0] = '\0';
char *ptr = NULL;
char *temp = NULL;
char *sp;
+ char *stop;
char delim_sep[] = "\r\n";
char temp_buf[BT_HF_DATA_BUF_SIZE] = {0,};
call_info = g_new0(hf_call_list_info_t, 1);
- sscanf(str, "+CLCC: %1d,%1d, %1d, %1d, %1d",
- &call_info->idx, &call_info->dir,
- &call_info->status, &call_info->mode,
- &call_info->multi_party);
- DBG("Index = [%d], Direction = [%d], Status = [%d], Mode = [%d], Multi_party = [%d]\n",
- call_info->idx, call_info->dir, call_info->status,
- call_info->mode, call_info->multi_party);
+ /* str format : "+CLCC: %1d,%1d, %1d, %1d, %1d" */
+ if ((ptr = strchr(str, ':')) != NULL) {
+ call_info->idx = strtol(ptr + 1, &stop, 10);
+ call_info->dir = strtol(stop + 1, &stop, 10);
+ call_info->status = strtol(stop + 1, &stop, 10);
+ call_info->mode = strtol(stop + 1, &stop, 10);
+ call_info->multi_party = strtol(stop + 1, &stop, 10);
+
+ DBG("Index = [%d], Direction = [%d], Status = [%d], Mode = [%d], Multi_party = [%d]\n",
+ call_info->idx, call_info->dir, call_info->status,
+ call_info->mode, call_info->multi_party);
+ }
ptr = strstr(str, "\"");
if (ptr) {
static int __bt_hf_agent_handler_ciev(bt_hf_agent_info_t *bt_hf_info, const char *buf)
{
- gchar indicator[BT_HF_INDICATOR_DESCR_SIZE + 4];
+ gchar *indicator;
gchar *sep;
+ gchar *ptr;
gint value;
guint index;
char fmt_str[BT_HF_FMT_STR_SIZE];
DBG("++++++++ __bt_hf_agent_handler_ciev +++++++++");
snprintf(fmt_str, sizeof(fmt_str), "\r\n+CIEV:%%%ds\r\n",
- (int)(sizeof(indicator) - 1));
- if (sscanf(buf, fmt_str, indicator) == 1) {
+ BT_HF_INDICATOR_DESCR_SIZE + 4 - 1);
+ if ((ptr = strchr(buf, ':')) != NULL) {
+ indicator = ptr + 1;
sep = strchr(indicator, ',');
sep[0] = '\0';
sep += 1;
{
DBG("+++++++++ __bt_hf_agent_handler_bvra +++++++++");
gint value;
- if (sscanf(buf, "\r\n+BVRA:%1d\r\n", &value) == 1)
+ gchar *ptr;
+ gchar *stop;
+ if ((ptr = strstr(buf, "BVRA:")) != NULL) {
+ value = strtol(ptr + 5, &stop, 10);
__bt_hf_agent_handle_voice_activation(value);
+ }
DBG("---------__bt_hf_agent_handler_bvra --------");
return 0;
static int __bt_hf_agent_handler_bcs(bt_hf_agent_info_t *bt_hf_info, const char *buf)
{
guint codec_id;
+ gchar *ptr;
+ gchar *stop;
DBG("+++++++++ __bt_hf_agent_handler_bcs +++++++++-");
- if (sscanf(buf, "\r\n+BCS:%3d\r\n", &codec_id))
+ if ((ptr = strstr(buf, "BCS:")) != NULL) {
+ codec_id = strtol(ptr + 4, &stop, 10);
__bt_hf_agent_handle_codec_select(bt_hf_info, codec_id);
+ }
DBG("---------__bt_hf_agent_handler_bcs --------");
return 0;
static int __bt_hf_agent_handler_vgs(bt_hf_agent_info_t *bt_hf_info, const char *buf)
{
gint value;
+ gchar *ptr;
+ gchar *stop;
DBG("+++++++++ __bt_hf_agent_handler_vgs +++++++++");
- if (sscanf(buf, "\r\n+VGS:%2d\r\n", &value))
+ if ((ptr = strstr(buf, "VGS:")) != NULL) {
+ value = strtol(ptr + 4, &stop, 10);
__bt_hf_agent_handle_speaker_gain(value);
+ }
DBG("---------__bt_hf_agent_handler_vgs --------");
static int __bt_hf_agent_handler_xsat(bt_hf_agent_info_t *bt_hf_info,
const char *buf)
{
- gint app_id;
- char msg[BT_HF_DATA_BUF_SIZE];
+ gint app_id = 0;
+ char *msg = NULL;
char fmt_str[BT_HF_CMD_BUF_SIZE];
+ char *ptr = NULL;
+ char *save_ptr = NULL;
+ char *stop = NULL;
DBG("+++++++++ __bt_hf_agent_handler_xsat +++++++++");
snprintf(fmt_str, sizeof(fmt_str), "\r\n+XSAT:%%d,%%%ds\r\n",
(int)(sizeof(msg) - 1));
- if (sscanf(buf, fmt_str, &app_id, msg)) {
+ ptr = strstr(buf, "XSAT:");
+ if (ptr)
+ app_id = strtol(ptr + 5, &stop, 10);
+
+ if (stop)
+ msg = strtok_r(stop + 1, "\\", &save_ptr);
+
+ if (app_id || msg) {
if (app_id == 2 && strstr(msg, "READTXPOWER")) {
char cmd_buf[BT_HF_CMD_BUF_SIZE * 2] = {0, };
char power = __bt_hf_agent_get_tx_power(bt_hf_info->remote_addr);
GSList *runner = indices;
gchar *cur = values - 1;
+ gchar *stop;
DBG("Indicator string = %s", values);
__bt_hf_agent_print_at_buffer("Indicator values :", values);
while (cur != NULL) {
cur += 1;
- sscanf(cur, "%1d", &val);
+ val = strtol(cur, &stop, 10);
cur = strchr(cur, ',');
ind = g_slist_nth_data(runner, 0);
ind->value = val;
gchar cmd_buf[BT_HF_CMD_BUF_SIZE] = {0};
gboolean ret;
char *buf_ptr;
+ char *stop;
guint feature = BT_HF_FEATURE_EC_ANDOR_NR |
BT_HF_FEATURE_CALL_WAITING_AND_3WAY |
BT_HF_FEATURE_CLI_PRESENTATION |
if (buf_ptr == NULL)
return FALSE;
- if (!ret || sscanf(buf_ptr, "\r\n+BRSF:%5d", &bt_hf_info->ag_features) != 1)
+ buf_ptr = strstr(buf_ptr, "BRSF:");
+ bt_hf_info->ag_features = strtol(buf_ptr + 5, &stop, 10);
+
+
+ if (!ret || !bt_hf_info->ag_features)
return FALSE;
INFO("Gateway supported features are 0x%X", bt_hf_info->ag_features);