From 8cf4912a49377e4ecec7a60a437000cda698081c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Mon, 13 Mar 2017 12:29:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86GSM07=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=88=90=E5=8A=9F=E6=88=AA=E5=8F=96?= =?UTF-8?q?=E5=B9=B6=E8=BD=AC=E5=8F=91=E7=BB=99=E4=B8=9A=E5=8A=A1=E5=B1=82?= =?UTF-8?q?=E3=80=82=20=E4=BB=A4=E7=89=8C=E6=8F=A1=E6=89=8B=E9=80=9A?= =?UTF-8?q?=E8=BF=87=EF=BC=8C=E8=B7=B3=E8=BD=AC=E6=88=90=E5=8A=9F=EF=BC=8C?= =?UTF-8?q?=E4=BD=86TokenController::Send=E5=87=BA=E7=8E=B0=E9=87=8A?= =?UTF-8?q?=E6=94=BE=E9=87=8E=E6=8C=87=E9=92=88=E5=86=85=E5=AD=98=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/AT.cpp | 3 ++- Drivers/GSM07.cpp | 21 ++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/App/AT.cpp b/App/AT.cpp index f2917e19..b7378b26 100644 --- a/App/AT.cpp +++ b/App/AT.cpp @@ -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)); diff --git a/Drivers/GSM07.cpp b/Drivers/GSM07.cpp index d679daa4..776577b3 100644 --- a/Drivers/GSM07.cpp +++ b/Drivers/GSM07.cpp @@ -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指令 ********************************/