stm405 ;rt-thread studio 1.1.5; at-2.03 ; rt-thread 4.02,中移物联的M6315模组
int gprs_socket_send(int socketid, const uint8_t *buf, const int buf_size, const int flags)
{
int ret;
at_response_t resp = RT_NULL;
char para_exp[32];
uint32_t event = 0;
int event_result;
if (buf == NULL || buf_size > AT_MAX_PAYLOAD_LEN || socketid >= MAX_SOCKET_NUM)
{
rt_kprintf("--->[Error] Invalid args \r\n");
return AT_INVALID_DATA;
}
//resp = at_create_resp(128, 2, 20 * RT_TICK_PER_SECOND);
resp = at_create_resp(128, 2, AT_IPSEND_TIMEOUT);
if (resp == RT_NULL)
{
//LOG_E("no memory for resp create.");
return -RT_ENOMEM;
}
// clear socket connect event
event = SET_EVENT(socketid, GPRS_EVENT_SEND_OK | GPRS_EVENT_SEND_FAIL);
gprs_socket_event_recv(event, 0, RT_EVENT_FLAG_OR);
at_set_end_sign('>');
memset(para_exp, 0, sizeof(para_exp));
snprintf(para_exp, sizeof(para_exp), "%s=%d,%d", AT_IPSEND, socketid, buf_size);
//ret = at_client_dev_cmd(para_exp, strlen(para_exp), ">", NULL, NULL);
ret = at_exec_cmd(resp, para_exp);
if (ret < 0)
{
rt_kprintf("--->[Error] 1gprs_socket_send_str fail ! ret=%d str=%s\r\n", ret, buf);
ret = -RT_ERROR;
goto __exit;
}
//ret = at_client_dev_cmd(buf, buf_size, "SEND OK", AT_IPSEND_RESP_LINE, NULL, NULL);
ret = at_client_send(buf, buf_size);
if (ret <= 0)
{
rt_kprintf("--->[Error] 2gprs_socket_send_str fail ! ret=%d str=%s\r\n", ret, buf);
ret = -RT_ERROR;
goto __exit;
}
// waiting result event from AT URC
event = SET_EVENT(socketid, 0);
if (gprs_socket_event_recv(event , 20 * RT_TICK_PER_SECOND, RT_EVENT_FLAG_OR) < 0)
{
LOG_E("device socket(%d) wait send result timeout.", socketid);
ret = -RT_ETIMEOUT;
goto __exit;
}
// waiting OK or failed result
event = SET_EVENT(socketid, GPRS_EVENT_SEND_OK | GPRS_EVENT_SEND_FAIL);
event_result = gprs_socket_event_recv(event , 15 * RT_TICK_PER_SECOND, RT_EVENT_FLAG_OR);
if (event_result < 0)
{
LOG_E("device socket(%d) wait send connect OK|FAIL timeout.", socketid);
ret = -RT_ETIMEOUT;
goto __exit;
}
// check result
if (event_result & GPRS_EVENT_SEND_FAIL)
{
LOG_E("device socket(%d) send failed.", socketid);
ret = -RT_ERROR;
goto __exit;
}
__exit:
/* reset the end sign for data conflict */
at_set_end_sign(0);
//rt_mutex_release(lock);
if (resp)
{
at_delete_resp(resp);
}
return ret;
}
协议
发送和接收数据情况
AT+QISEND=0,6
这个正确
AT+QISEND=0,87
这个就不符合要求了
什么会出现这样的情况呢?是at组件问题? 还是6315模块问题?