处理GSM07响应数据,成功截取并转发给业务层。

令牌握手通过,跳转成功,但TokenController::Send出现释放野指针内存错误
This commit is contained in:
大石头 2017-03-13 12:29:35 +08:00
parent 67a66f94b9
commit 8cf4912a49
2 changed files with 22 additions and 2 deletions

View File

@ -322,7 +322,8 @@ uint AT::OnReceive(Buffer& bs, void* param)
// +IPD开头的数据作为收到数据
if (p >= 0)
{
if (p + 5 >= bs.Length())
p += String(DataKey).Length();
if (p >= bs.Length())
{
#if NET_DEBUG
ParseFail("+IPD<=5", bs.Sub(p, -1));

View File

@ -315,7 +315,26 @@ Socket* GSM07::CreateSocket(NetType type)
// 数据到达
void GSM07::OnReceive(Buffer& bs)
{
Received(bs);
// +CIPRCV:61,xxx
auto str = bs.AsString();
int p = str.IndexOf(",");
if (p <= 0) return;
int len = str.Substring(0, p).ToInt();
// 检查长度
if (p + 1 + len > bs.Length()) len = bs.Length() - p - 1;
auto data = bs.Sub(p + 1, len);
Received(data);
// 分发到各个Socket
int idx = 0;
auto es = (GSMSocket**)_sockets;
auto sk = es[idx];
if (sk)
{
sk->OnProcess(data, _Remote);
}
}
/******************************** 基础AT指令 ********************************/