|
@@ -10,7 +10,7 @@
|
|
|
* 1 V0.0.1 实现4GAT指令 何龙翔 2023/12/10
|
|
* 1 V0.0.1 实现4GAT指令 何龙翔 2023/12/10
|
|
|
* 2 V0.0.2 基于4实现NB指令 刘艳斌 2024/1/10
|
|
* 2 V0.0.2 基于4实现NB指令 刘艳斌 2024/1/10
|
|
|
* 3 V0.0.3 整合4g和nb代码 刘艳斌 2024/1/24
|
|
* 3 V0.0.3 整合4g和nb代码 刘艳斌 2024/1/24
|
|
|
- *
|
|
|
|
|
|
|
+ * 4 V0.0.4 修改send函数添加sendrai 刘艳斌 2024/2/18
|
|
|
******************************************************************************
|
|
******************************************************************************
|
|
|
*/
|
|
*/
|
|
|
#include "stm32f10x.h"
|
|
#include "stm32f10x.h"
|
|
@@ -142,6 +142,7 @@ enum Result bc260y_set_qisde_sync(uint8_t echo); // 同
|
|
|
*
|
|
*
|
|
|
**/
|
|
**/
|
|
|
enum Result bc260y_send(uint8_t connectID, uint8_t * data, uint16_t data_length);
|
|
enum Result bc260y_send(uint8_t connectID, uint8_t * data, uint16_t data_length);
|
|
|
|
|
+enum Result bc260y_send_rai(uint8_t connectID, uint8_t * data, uint16_t data_length,uint8_t rai);
|
|
|
enum Result bc260y_send_sync(uint8_t connectID, uint8_t * data, uint16_t data_length); // 同步
|
|
enum Result bc260y_send_sync(uint8_t connectID, uint8_t * data, uint16_t data_length); // 同步
|
|
|
/**
|
|
/**
|
|
|
* 接收数据
|
|
* 接收数据
|
|
@@ -248,6 +249,7 @@ struct BC260Y bc260y =
|
|
|
.set_qisde = bc260y_set_qisde,
|
|
.set_qisde = bc260y_set_qisde,
|
|
|
.set_qisde_sync = bc260y_set_qisde_sync,
|
|
.set_qisde_sync = bc260y_set_qisde_sync,
|
|
|
.send = bc260y_send,
|
|
.send = bc260y_send,
|
|
|
|
|
+ .send_rai = bc260y_send_rai,
|
|
|
.send_sync = bc260y_send_sync,
|
|
.send_sync = bc260y_send_sync,
|
|
|
.recv = bc260y_recv,
|
|
.recv = bc260y_recv,
|
|
|
.recv_with_time = bc260y_recv_with_time,
|
|
.recv_with_time = bc260y_recv_with_time,
|
|
@@ -1250,6 +1252,7 @@ enum Result bc260y_send(uint8_t connectID, uint8_t * data, uint16_t data_length)
|
|
|
{
|
|
{
|
|
|
Log_Printf_Debug("AT指令返回超时\r\n"); // 打印日志
|
|
Log_Printf_Debug("AT指令返回超时\r\n"); // 打印日志
|
|
|
result = overtime(); // 超时
|
|
result = overtime(); // 超时
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
else if(strstr((char * )AT_result(), "SEND OK\r\n") != NULL) // 查询是否返回
|
|
else if(strstr((char * )AT_result(), "SEND OK\r\n") != NULL) // 查询是否返回
|
|
|
{
|
|
{
|
|
@@ -1278,6 +1281,68 @@ enum Result bc260y_send(uint8_t connectID, uint8_t * data, uint16_t data_length)
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+/**
|
|
|
|
|
+* 发送数据
|
|
|
|
|
+* 输入<<
|
|
|
|
|
+* connectID Socket ID。范围1-11。
|
|
|
|
|
+* send_length 发送长度。
|
|
|
|
|
+* data 待发送的数据。
|
|
|
|
|
+*rai 发送模式,0发送不释放RRC,1发送立即释放RRC,发送返回释放RRC
|
|
|
|
|
+* activeID 49
|
|
|
|
|
+**/
|
|
|
|
|
+enum Result bc260y_send_rai(uint8_t connectID, uint8_t * data, uint16_t data_length,uint8_t rai)
|
|
|
|
|
+{
|
|
|
|
|
+ enum Result result = Result_None;
|
|
|
|
|
+ char hexData[1024] = {0};
|
|
|
|
|
+
|
|
|
|
|
+ int activeID = 49, time = 10000; // 活动ID, 超时时间
|
|
|
|
|
+ // 校验ID
|
|
|
|
|
+ if(!verifyActiveID(activeID)){ return Result_Failed; }
|
|
|
|
|
+
|
|
|
|
|
+ // 判断状态
|
|
|
|
|
+ if(getStatus() == Status_None) // 空闲状态
|
|
|
|
|
+ {
|
|
|
|
|
+ byteToHexStr(data,hexData, data_length);//nb需要转16进制
|
|
|
|
|
+ sprintf(AT_CMD, "AT+QISEND=%d,%d,%s,%d\r\r\n", connectID, data_length,hexData,rai); // 拼接AT指令
|
|
|
|
|
+ result = send_at(AT_CMD, activeID);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(getStatus() != Status_Sending) // 上一次的结果没有清除,返回错误,为了保证时效性,需要重置状态。重新调用
|
|
|
|
|
+ {
|
|
|
|
|
+ Log_Printf_Debug("返回结果过期,请重置状态\r\n"); // 打印日志
|
|
|
|
|
+ result = Result_Failed;
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(getTimerMs() > time) // 正在发送状态。判断超时
|
|
|
|
|
+ {
|
|
|
|
|
+ Log_Printf_Debug("AT指令返回超时\r\n"); // 打印日志
|
|
|
|
|
+ result = overtime(); // 超时
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(strstr((char * )AT_result(), "SEND OK\r\n") != NULL) // 查询是否返回
|
|
|
|
|
+ {
|
|
|
|
|
+ // 发送日志
|
|
|
|
|
+ Log_Printf_Debug("AT返回: %d\r\n", AT_result_length());
|
|
|
|
|
+ Log_SendArray_Debug(AT_result(), AT_result_length());
|
|
|
|
|
+
|
|
|
|
|
+ result = success(); // 成功
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(strstr((char * )AT_result(), "SEND FALL\r\n") != NULL) // 查询是否返回
|
|
|
|
|
+ {
|
|
|
|
|
+ // 发送日志
|
|
|
|
|
+ Log_Printf_Debug("AT返回: %d\r\n", AT_result_length());
|
|
|
|
|
+ Log_SendArray_Debug(AT_result(), AT_result_length());
|
|
|
|
|
+
|
|
|
|
|
+ result = failed(); // 失败
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(strstr((char * )AT_result(), "ERROR\r\n") != NULL) // 查询是否返回
|
|
|
|
|
+ {
|
|
|
|
|
+ // 发送日志
|
|
|
|
|
+ Log_Printf_Debug("AT返回: %d\r\n", AT_result_length());
|
|
|
|
|
+ Log_SendArray_Debug(AT_result(), AT_result_length());
|
|
|
|
|
+
|
|
|
|
|
+ result = failed(); // 失败
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 发送数据
|
|
* 发送数据
|