解决URC表匹配第一项的问题。

This commit is contained in:
魔罗技术 2021-03-04 20:21:47 +08:00
parent 93c7ab71ff
commit 44cd306a95
2 changed files with 10 additions and 8 deletions

View File

@ -327,10 +327,10 @@ static void urc_handler_entry(at_obj_t *at, char *urc, unsigned int size)
{
int i, n;
utc_item_t *tbl = at->adap.utc_tbl;
for (i = 0; i < at->adap.urc_tbl_count; i++) {
for (i = 0; i < at->adap.urc_tbl_count; i++, tbl++) {
n = strlen(tbl->prefix);
if (strncmp(urc, tbl->prefix, n) == 0) { /* 匹配前缀 */
tbl[i].handler(urc, size); /* 回调处理*/
tbl->handler(urc, size); /* 回调处理*/
break;
}
}
@ -354,8 +354,9 @@ static void urc_recv_process(at_obj_t *at, char *buf, unsigned int size)
if (size == 0 && at->urc_cnt > 0) {
if (AT_IS_TIMEOUT(at->urc_timer, 2000)) { /* 接收超时*/
urc_handler_entry(at, urc_buf, at->urc_cnt);
at->urc_cnt = 0;
if (at->urc_cnt > 1)
AT_DEBUG("Urc recv timeout.\r\n");
at->urc_cnt = 0;
}
} else if (urc_buf != NULL){
at->urc_timer = AT_GET_TICK();

View File

@ -327,10 +327,10 @@ static void urc_handler_entry(at_obj_t *at, char *urc, unsigned int size)
{
int i, n;
utc_item_t *tbl = at->adap.utc_tbl;
for (i = 0; i < at->adap.urc_tbl_count; i++) {
for (i = 0; i < at->adap.urc_tbl_count; i++, tbl++) {
n = strlen(tbl->prefix);
if (strncmp(urc, tbl->prefix, n) == 0) { /* 匹配前缀 */
tbl[i].handler(urc, size); /* 回调处理*/
tbl->handler(urc, size); /* 回调处理*/
break;
}
}
@ -354,8 +354,9 @@ static void urc_recv_process(at_obj_t *at, char *buf, unsigned int size)
if (size == 0 && at->urc_cnt > 0) {
if (AT_IS_TIMEOUT(at->urc_timer, 2000)) { /* 接收超时*/
urc_handler_entry(at, urc_buf, at->urc_cnt);
at->urc_cnt = 0;
if (at->urc_cnt > 1)
AT_DEBUG("Urc recv timeout.\r\n");
at->urc_cnt = 0;
}
} else if (urc_buf != NULL){
at->urc_timer = AT_GET_TICK();