修正消息中的传输速度

This commit is contained in:
nnhy 2015-08-22 01:51:51 +00:00
parent 692ca31fed
commit 2812489c4b
3 changed files with 12 additions and 6 deletions

View File

@ -21,7 +21,7 @@ public:
byte Address; // 分配得到的设备地址
byte Server; // 网关ID
byte Channel; // 通道
byte Speed; // 传输速度
ushort Speed; // 传输速度
byte ServerKey[16]; // 服务端组网密码退网时使用。一般6字节
ushort PingTime; // 心跳时间。秒

View File

@ -258,13 +258,17 @@ bool TinyClient::OnJoin(TinyMessage& msg)
// 记住服务端地址
Server = dm.Server;
Config.Channel = dm.Channel;
Config.Speed = dm.Speed == 0 ? 250 : (dm.Speed == 1 ? 1000 : 2000);;
debug_printf("组网成功!由网关 0x%02X 分配得到节点地址 0x%02X ,频道:%d密码", Server, dm.Address, dm.Channel);
debug_printf("组网成功!由网关 0x%02X 分配得到节点地址 0x%02X ,频道:%d传输速率:%dkbps密码:", Server, dm.Address, dm.Channel, Config.Speed);
Password.Show(true);
// 取消Join任务启动Ping任务
Task* task = Scheduler[_TaskID];
task->Period = Config.PingTime;
ushort time = Config.PingTime;
if(time < 5) time = 5;
task->Period = time * 1000000;
// 组网成功更新一次最后活跃时间
LastActive = Time.Current();
@ -281,11 +285,13 @@ bool TinyClient::OnDisjoin(TinyMessage& msg)
// 心跳
void TinyClient::Ping()
{
if(LastActive > 0 && LastActive + Config.OfflineTime * 1000000 < Time.Current())
ushort off = Config.OfflineTime;
if(off < 10) off = 10;
if(LastActive > 0 && LastActive + off * 1000000 < Time.Current())
{
if(Server == 0) return;
debug_printf("%d 秒无法联系服务端可能已经掉线重启Join任务关闭Ping任务\r\n", Config.OfflineTime);
debug_printf("%d 秒无法联系服务端可能已经掉线重启Join任务关闭Ping任务\r\n", off);
Task* task = Scheduler[_TaskID];
task->Period = 5000000;

View File

@ -191,7 +191,7 @@ bool TinyServer::OnJoin(TinyMessage& msg)
dm.Server = Config.Address;
dm.Channel = Config.Channel;
dm.Speed = Config.Speed;
dm.Speed = Config.Speed == 250 ? 0 : (Config.Speed == 1000 ? 1 : 2);;
dm.Address = dv->Address;
dm.Password = dv->Pass;