|
|
|
@ -96,22 +96,30 @@ namespace FBeeService
|
|
|
|
|
this.DeviceOnOff(id, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DeviceOnOff(string id, byte status)
|
|
|
|
|
private void DeviceOnOff(string ieee, byte status)
|
|
|
|
|
{
|
|
|
|
|
var sn = id.Split('-')[0];
|
|
|
|
|
var address = id.Split('-')[1];
|
|
|
|
|
var list = new List<byte>() { 0x16, 0x00 };
|
|
|
|
|
list.AddRange(sn.HexToBytes().Reverse());
|
|
|
|
|
list.Add(0xfe);
|
|
|
|
|
list.Add(0x82);
|
|
|
|
|
list.Add(0x0d);
|
|
|
|
|
list.Add(0x02);
|
|
|
|
|
list.AddRange(address.HexToBytes());
|
|
|
|
|
list.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
|
|
|
|
|
list.Add(0x01);
|
|
|
|
|
list.AddRange(new byte[] { 0x00, 0x00 });
|
|
|
|
|
list.Add(status);
|
|
|
|
|
this.Clients[sn].Client.GetStream().Write(list.ToArray());
|
|
|
|
|
using (var scope = _applicationServices.CreateScope())
|
|
|
|
|
{
|
|
|
|
|
var repo = scope.ServiceProvider.GetService<IRepository<FBeeDevice>>();
|
|
|
|
|
var device = repo.ReadOnlyTable().FirstOrDefault(o => o.Online != 0 && o.IEEE == ieee);
|
|
|
|
|
if (device != null)
|
|
|
|
|
{
|
|
|
|
|
var sn = device.Sn;
|
|
|
|
|
var address = device.Address;
|
|
|
|
|
var list = new List<byte>() { 0x16, 0x00 };
|
|
|
|
|
list.AddRange(sn.HexToBytes().Reverse());
|
|
|
|
|
list.Add(0xfe);
|
|
|
|
|
list.Add(0x82);
|
|
|
|
|
list.Add(0x0d);
|
|
|
|
|
list.Add(0x02);
|
|
|
|
|
list.AddRange(address.HexToBytes());
|
|
|
|
|
list.AddRange(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
|
|
|
|
|
list.Add(0x01);
|
|
|
|
|
list.AddRange(new byte[] { 0x00, 0x00 });
|
|
|
|
|
list.Add(status);
|
|
|
|
|
this.Clients[sn].Client.GetStream().Write(list.ToArray());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Switch2AllOn(string id)
|
|
|
|
@ -383,7 +391,6 @@ namespace FBeeService
|
|
|
|
|
device = new FBeeDevice
|
|
|
|
|
{
|
|
|
|
|
Sn = sn,
|
|
|
|
|
Number = $"{sn}-{address}",
|
|
|
|
|
Name = deviceType.Name,
|
|
|
|
|
Icon = deviceType.Icon,
|
|
|
|
|
CategoryNumber = deviceType.RawDeviceId,
|
|
|
|
|