diff options
Diffstat (limited to 'fw/fe310/eos/net/cell.c')
-rw-r--r-- | fw/fe310/eos/net/cell.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/fw/fe310/eos/net/cell.c b/fw/fe310/eos/net/cell.c index 96216ba..c0c77af 100644 --- a/fw/fe310/eos/net/cell.c +++ b/fw/fe310/eos/net/cell.c @@ -10,21 +10,21 @@ static eos_evt_handler_t evt_handler[EOS_CELL_MAX_MTYPE]; -static void cell_handle_msg(unsigned char type, unsigned char *buffer, uint16_t len) { +static void cell_handle_msg(unsigned char type, unsigned char *buffer, uint16_t buf_len) { unsigned char mtype; unsigned char idx; - if ((buffer == NULL) || (len < 1)) { - eos_net_bad_handler(type, buffer, len); + if ((buffer == NULL) || (buf_len < 1)) { + eos_net_bad_handler(type, buffer, buf_len); return; } mtype = buffer[0]; idx = (mtype & EOS_CELL_MTYPE_MASK) >> 4; if ((idx < EOS_CELL_MAX_MTYPE) && evt_handler[idx]) { - evt_handler[idx](mtype & ~EOS_CELL_MTYPE_MASK, buffer, len); + evt_handler[idx](mtype & ~EOS_CELL_MTYPE_MASK, buffer, buf_len); } else { - eos_net_bad_handler(type, buffer, len); + eos_net_bad_handler(type, buffer, buf_len); } } @@ -52,32 +52,32 @@ eos_evt_handler_t eos_cell_get_handler(unsigned char mtype) { int eos_cell_send_buffer(unsigned char *buffer, uint16_t buf_len, uint16_t offset, int sync) { buffer -= offset; - return eos_net_send_async(EOS_NET_MTYPE_CELL, buffer, buf_len + offset, 1); + return _eos_net_send(EOS_NET_MTYPE_CELL, buffer, buf_len + offset, !sync, 1); } -int eos_cell_status_parse(unsigned char *buffer, uint16_t len, uint8_t *status, uint8_t *connected) { - if (len < 2) return EOS_ERR_SIZE; +int eos_cell_status_parse(unsigned char *buffer, uint16_t buf_len, uint8_t *status, uint8_t *connected) { + if (buf_len < 2) return EOS_ERR_SIZE; if (buffer[0] != (EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_STATUS)) return EOS_ERR_NET; buffer++; - len--; + buf_len--; *status = buffer[0]; buffer++; - len--; + buf_len--; if (*status == EOS_CELL_STATUS_PPP) { - if (len < 1) return EOS_ERR_SIZE; + if (buf_len < 1) return EOS_ERR_SIZE; if (connected) *connected = buffer[0]; buffer++; - len--; + buf_len--; } return EOS_OK; } int eos_cell_status(uint8_t *status, uint8_t *connected, unsigned char *buffer) { unsigned char type; - uint16_t len; + uint16_t buf_len; int do_release; int rv; @@ -88,10 +88,10 @@ int eos_cell_status(uint8_t *status, uint8_t *connected, unsigned char *buffer) } type = EOS_NET_MTYPE_CELL; - len = 1; + buf_len = 1; buffer[0] = EOS_CELL_MTYPE_DEV | EOS_CELL_MTYPE_STATUS; - rv = eos_net_xchg(&type, buffer, &len); + rv = eos_net_xchg(&type, buffer, &buf_len); if (rv) goto cell_status_fin; if (type != EOS_NET_MTYPE_CELL) { @@ -99,7 +99,7 @@ int eos_cell_status(uint8_t *status, uint8_t *connected, unsigned char *buffer) goto cell_status_fin; } - rv = eos_cell_status_parse(buffer, len, status, connected); + rv = eos_cell_status_parse(buffer, buf_len, status, connected); cell_status_fin: if (do_release) eos_net_free(buffer, 1); @@ -132,7 +132,7 @@ int eos_cell_uart_give(unsigned char *buffer, int sync) { return _eos_net_send(EOS_NET_MTYPE_CELL, buffer, 1, async, 1); } -unsigned char *eos_cell_uart_data_buffer(uint16_t *offset) { +unsigned char *eos_cell_uart_data_alloc(uint16_t *offset) { unsigned char *buffer; buffer = eos_net_alloc(); @@ -185,7 +185,7 @@ int eos_cell_voice_hangup(unsigned char *buffer, int sync) { return _eos_net_send(EOS_NET_MTYPE_CELL, buffer, 1, async, 1); } -unsigned char *eos_cell_voice_pcm_buffer(uint16_t *offset) { +unsigned char *eos_cell_voice_pcm_alloc(uint16_t *offset) { unsigned char *buffer; buffer = eos_net_alloc(); @@ -197,7 +197,7 @@ unsigned char *eos_cell_voice_pcm_buffer(uint16_t *offset) { int eos_cell_sms_send(char *addr, char *txt, unsigned char *buffer, int sync) { int async; size_t addr_len, txt_len; - uint16_t len; + uint16_t buf_len; addr_len = strlen(addr); txt_len = strlen(txt); @@ -221,48 +221,48 @@ int eos_cell_sms_send(char *addr, char *txt, unsigned char *buffer, int sync) { buffer[3] = EOS_CELL_SMS_ADDRTYPE_OTHER; } buffer[4] = addr_len; - len = 5; - memcpy(buffer + len, addr, addr_len); - len += addr_len; - memcpy(buffer + len, txt, txt_len); - len += txt_len; - return _eos_net_send(EOS_NET_MTYPE_CELL, buffer, len, async, 1); + buf_len = 5; + memcpy(buffer + buf_len, addr, addr_len); + buf_len += addr_len; + memcpy(buffer + buf_len, txt, txt_len); + buf_len += txt_len; + return _eos_net_send(EOS_NET_MTYPE_CELL, buffer, buf_len, async, 1); } -int _eos_cell_sms_parse(unsigned char *buffer, uint16_t len, char **addr, uint16_t *addr_len, char **txt, uint16_t *txt_len) { +int _eos_cell_sms_parse(unsigned char *buffer, uint16_t buf_len, char **addr, uint16_t *addr_len, char **txt, uint16_t *txt_len) { uint16_t _addr_len; - if (len < 4 + EOS_CELL_SMS_SIZE_TS) return EOS_ERR_SIZE; + if (buf_len < 4 + EOS_CELL_SMS_SIZE_TS) return EOS_ERR_SIZE; if (buffer[0] != (EOS_CELL_MTYPE_SMS | EOS_CELL_MTYPE_SMS_MSG)) return EOS_ERR_NET; buffer += 3 + EOS_CELL_SMS_SIZE_TS; - len -= 3 + EOS_CELL_SMS_SIZE_TS; + buf_len -= 3 + EOS_CELL_SMS_SIZE_TS; _addr_len = *buffer; if (_addr_len > EOS_CELL_SMS_SIZE_ADDR) return EOS_ERR_SIZE; - if ((_addr_len == 0) || (len < (_addr_len + 1))) return EOS_ERR_SIZE; + if ((_addr_len == 0) || (buf_len < (_addr_len + 1))) return EOS_ERR_SIZE; if (addr && addr_len) { *addr = buffer + 1; *addr_len = _addr_len; } buffer += _addr_len + 1; - len -= _addr_len + 1; + buf_len -= _addr_len + 1; - if (len > EOS_CELL_SMS_SIZE_TXT) return EOS_ERR_SIZE; + if (buf_len > EOS_CELL_SMS_SIZE_TXT) return EOS_ERR_SIZE; if (txt && txt_len) { *txt = buffer; - *txt_len = len; + *txt_len = buf_len; } return EOS_OK; } -int eos_cell_sms_parse(unsigned char *buffer, uint16_t len, char *addr, uint16_t addr_size, char *txt, uint16_t txt_size) { +int eos_cell_sms_parse(unsigned char *buffer, uint16_t buf_len, char *addr, uint16_t addr_size, char *txt, uint16_t txt_size) { char *_addr, *_txt; uint16_t _addr_len, _txt_len; int rv; - rv = _eos_cell_sms_parse(buffer, len, &_addr, &_addr_len, &_txt, &_txt_len); + rv = _eos_cell_sms_parse(buffer, buf_len, &_addr, &_addr_len, &_txt, &_txt_len); if (rv) return rv; if (addr_size < _addr_len + 1) return EOS_ERR_SIZE; if (txt_size < _txt_len + 1) return EOS_ERR_SIZE; @@ -276,7 +276,7 @@ int eos_cell_sms_parse(unsigned char *buffer, uint16_t len, char *addr, uint16_t int eos_cell_pdp_get(unsigned char atype, char *arg, uint16_t arg_size, unsigned char *buffer) { unsigned char type; - uint16_t len; + uint16_t buf_len; int do_release; int rv; @@ -287,24 +287,24 @@ int eos_cell_pdp_get(unsigned char atype, char *arg, uint16_t arg_size, unsigned } type = EOS_NET_MTYPE_CELL; - len = 1; + buf_len = 1; buffer[0] = EOS_CELL_MTYPE_PDP | atype; - rv = eos_net_xchg(&type, buffer, &len); + rv = eos_net_xchg(&type, buffer, &buf_len); if (rv) goto cell_pdp_get_fin; - if ((type != EOS_NET_MTYPE_CELL) || (len == 0) || (buffer[0] != EOS_CELL_MTYPE_PDP | atype)) { + if ((type != EOS_NET_MTYPE_CELL) || (buf_len == 0) || (buffer[0] != EOS_CELL_MTYPE_PDP | atype)) { rv = EOS_ERR_NET; goto cell_pdp_get_fin; } - len--; - if ((len > EOS_CELL_PDP_SIZE_ARG) || (len > arg_size - 1)) { + buf_len--; + if ((buf_len > EOS_CELL_PDP_SIZE_ARG) || (buf_len > arg_size - 1)) { rv = EOS_ERR_SIZE; goto cell_pdp_get_fin; } - memcpy(buffer + 1, arg, len); - arg[len] = '\0'; + memcpy(buffer + 1, arg, buf_len); + arg[buf_len] = '\0'; cell_pdp_get_fin: if (do_release) eos_net_free(buffer, 1); |