MaJerle / lwcell

Lightweight cellular modem host AT library
MIT License
395 stars 147 forks source link

Read phonebook entry bug #56

Closed vsanisimova closed 3 years ago

vsanisimova commented 3 years ago

I noticed a bug in parsing the response to the AT+CPBR command. According to the documentation on SIM900 (or other GSM module), the response to this command looks like +CPBR:<index1>,<number>,<type>,text

However, parsing in the _gsm_parsecpbr function (gsm_parser.c ~800 line) occurs for the case when the name comes first, then the type and number:

e = &lwgsm.msg->msg.pb_list.entries[lwgsm.msg->msg.pb_list.ei]; e->pos = LWGSM_SZ(lwgsmi_parse_number(&str)); lwgsmi_parse_string(&str, e->name, sizeof(e->name), 1); e->type = (lwgsm_number_type_t)lwgsmi_parse_number(&str); lwgsmi_parse_string(&str, e->number, sizeof(e->number), 1);

This is the reason for the incorrect display of information in _gsm_pb_entryt structure.

I think it should be:

e = &lwgsm.msg->msg.pb_list.entries[lwgsm.msg->msg.pb_list.ei]; e->pos = LWGSM_SZ(lwgsmi_parse_number(&str)); lwgsmi_parse_string(&str, e->number, sizeof(e->number), 1); e->type = (lwgsm_number_type_t)lwgsmi_parse_number(&str); lwgsmi_parse_string(&str, e->name, sizeof(e->name), 1);

MaJerle commented 3 years ago

Could you please make a pull request?