节点启动时使用保存的网关MAC作为远程地址,如果超过1分钟未能心跳成功,则节点抹去远程地址再重启
This commit is contained in:
parent
eb39120a1e
commit
d246b8059a
|
@ -69,15 +69,19 @@ ITransport* Create2401(SPI_TypeDef* spi_, Pin ce, Pin irq, Pin power, bool power
|
||||||
auto spi = new Spi(spi_, 10000000, true);
|
auto spi = new Spi(spi_, 10000000, true);
|
||||||
auto nrf = new NRF24L01();
|
auto nrf = new NRF24L01();
|
||||||
nrf->Init(spi, ce, irq, power);
|
nrf->Init(spi, ce, irq, power);
|
||||||
//nrf->Power.Invert = powerInvert;
|
|
||||||
|
|
||||||
|
auto tc = TinyConfig::Current;
|
||||||
nrf->AutoAnswer = false;
|
nrf->AutoAnswer = false;
|
||||||
nrf->PayloadWidth = 32;
|
nrf->PayloadWidth = 32;
|
||||||
nrf->Channel = TinyConfig::Current->Channel;
|
//nrf->Channel = tc->Channel;
|
||||||
nrf->Speed = TinyConfig::Current->Speed;
|
nrf->Channel = 120;
|
||||||
|
nrf->Speed = tc->Speed;
|
||||||
|
|
||||||
nrf->FixData= Fix2401;
|
nrf->FixData = Fix2401;
|
||||||
nrf->Led = led;
|
nrf->Led = led;
|
||||||
|
|
||||||
|
byte num = tc->Mac[0] && tc->Mac[1] && tc->Mac[2] && tc->Mac[3] && tc->Mac[4];
|
||||||
|
if(num != 0 && num != 0xFF) memcpy(nrf->Remote, tc->Mac, 5);
|
||||||
|
|
||||||
return nrf;
|
return nrf;
|
||||||
}
|
}
|
||||||
|
|
|
@ -474,12 +474,13 @@ bool TinyClient::OnJoin(const TinyMessage& msg)
|
||||||
{
|
{
|
||||||
//todo 设置zigbee 通道
|
//todo 设置zigbee 通道
|
||||||
}
|
}
|
||||||
Cfg->Channel = dm.Channel;
|
Cfg->Channel = dm.Channel;
|
||||||
Cfg->Speed = dm.Speed * 10;
|
Cfg->Speed = dm.Speed * 10;
|
||||||
|
|
||||||
// 服务端组网密码,退网使用
|
// 服务端组网密码,退网使用
|
||||||
Cfg->Mac[0] = dm.HardID.Length();
|
//Cfg->Mac[0] = dm.HardID.Length();
|
||||||
dm.HardID.Save(Cfg->Mac, ArrayLength(Cfg->Mac));
|
//dm.HardID.Save(Cfg->Mac, ArrayLength(Cfg->Mac));
|
||||||
|
dm.HardID.CopyTo(Cfg->Mac);
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//debug_printf("组网成功!\r\n");
|
//debug_printf("组网成功!\r\n");
|
||||||
|
@ -567,6 +568,11 @@ void TinyClient::Ping()
|
||||||
// 掉线以后,重发组网信息,基本功能继续执行
|
// 掉线以后,重发组网信息,基本功能继续执行
|
||||||
Joining = true;
|
Joining = true;
|
||||||
|
|
||||||
|
auto tc = TinyConfig::Current;
|
||||||
|
memset(tc->Mac, 0, 5);
|
||||||
|
tc->Save();
|
||||||
|
|
||||||
|
Sys.Reset();
|
||||||
//Server = 0;
|
//Server = 0;
|
||||||
//Password.SetLength(0);
|
//Password.SetLength(0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue