透传,配置

This commit is contained in:
cdyong 2016-08-08 07:01:33 +00:00
parent 10c5b9bf00
commit 967d605084
4 changed files with 54 additions and 11 deletions

View File

@ -128,7 +128,7 @@ ISocketHost* AP0801::Create8266(bool apOnly)
//Sys.AddTask(SetWiFiTask, this, 0, -1, "SetWiFi"); //Sys.AddTask(SetWiFiTask, this, 0, -1, "SetWiFi");
Client->Register("SetWiFi", &Esp8266::SetWiFi, host); Client->Register("SetWiFi", &Esp8266::SetWiFi, host);
Client->Register("SetWiFi", &Esp8266::GetWiFi, host); Client->Register("GetWiFi", &Esp8266::GetWiFi, host);
host->OpenAsync(); host->OpenAsync();

View File

@ -40,9 +40,16 @@ TokenClient::TokenClient()
NextReport = 0; NextReport = 0;
ReportLength = 0; ReportLength = 0;
// 重启
this->Register("Gateway/Restart", InvokeRestStart, this); this->Register("Gateway/Restart", InvokeRestStart, this);
// 重置
this->Register("Gateway/Reset", InvokeRestBoot, this); this->Register("Gateway/Reset", InvokeRestBoot, this);
// 透传
this->Register("Message/Transparent", InvokeMessage, this);
// 设置配置
this->Register("Config/Set", InvokeConfigSet, this);
// 获取配置
this->Register("Config/Get", InvokeConfigGet, this);
} }
@ -926,7 +933,7 @@ void TokenClient::OnInvoke(const TokenMessage& msg, TokenController* ctrl)
if (result.Position() > 0) if (result.Position() > 0)
{ {
// rs.SetError(0x03, (cstring)result.GetBuffer()); // rs.SetError(0x03, (cstring)result.GetBuffer());
rsbp.Set("ErrorCode",(byte)0x03); rsbp.Set("ErrorCode", (byte)0x03);
} }
else else
{ {
@ -1007,3 +1014,31 @@ bool TokenClient::InvokeRestBoot(void * param, const BinaryPair& args, Stream& r
return true; return true;
} }
bool TokenClient::InvokeMessage(void * param, const BinaryPair& args, Stream& result)
{
byte id;
ByteArray data;
if (!args.Get("id", id)) return false;
if (!args.Get("data", data)) return false;
// 拿到数据根据ID分发给各个串口
//测试,原样返回结果
//result.Write("id");
result.Write(id);
//result.Write("data")
result.Write(data);
return true;
}
bool TokenClient::InvokeConfigGet(void * param, const BinaryPair& args, Stream& result)
{
}
bool TokenClient::InvokeConfigSet(void * param, const BinaryPair& args, Stream& result)
{
}

View File

@ -104,9 +104,17 @@ private:
void OnInvoke(const TokenMessage& msg, TokenController* ctrl); void OnInvoke(const TokenMessage& msg, TokenController* ctrl);
bool OnInvoke(const String& action, const BinaryPair& args, Stream& result); bool OnInvoke(const String& action, const BinaryPair& args, Stream& result);
// 重启,重置
static bool InvokeRestStart(void * param, const BinaryPair& args, Stream& result); static bool InvokeRestStart(void * param, const BinaryPair& args, Stream& result);
static bool InvokeRestBoot(void * param, const BinaryPair& args, Stream& result); static bool InvokeRestBoot(void * param, const BinaryPair& args, Stream& result);
//配置
static bool InvokeConfigSet(void * param, const BinaryPair& args, Stream& result);
static bool InvokeConfigGet(void * param, const BinaryPair& args, Stream& result);
//透传消息
static bool InvokeMessage(void * param, const BinaryPair& args, Stream& result);
private: private:
uint _task; uint _task;
uint _taskBroadcast; // 广播任务 uint _taskBroadcast; // 广播任务