Beispiel #1
0
        private bool SetBitronHomeDevice()
        {
            m_testedDevice   = null;
            m_testedEndPoint = null;
            int nb_trial = 100;

            while (nb_trial > 0)
            {
                if (m_zigBeeAdapter.DeviceList.TryGetValue(BITRON_HOME_DOOR_SENSOR_MAC_ADDRESS, out m_testedDevice) &&
                    m_testedDevice.EndPointList.TryGetValue(BITRON_HOME_DOOR_SENSOR_END_POINT, out m_testedEndPoint))
                {
                    Debug.WriteLine("End point: {0} - {1} - Mac address: 0x{2:X}, Id: 0x{3:X2}, ZigBee profile 0x{4:X4}",
                                    m_testedEndPoint.Vendor, m_testedEndPoint.Model, m_testedDevice.MacAddress, m_testedEndPoint.Id, m_testedEndPoint.CommandProfileId);
                    break;
                }
                else
                {
                    Debug.WriteLine("Wait for BitronDevice - {0}", nb_trial);
                    System.Threading.Tasks.Task.Delay(1000).Wait();
                    nb_trial--;
                }
            }

            if (m_testedDevice != null &&
                m_testedEndPoint != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        public override void ProcessData(ZigBeeCoordinatorContext ctx, ZigBeeDevice device, byte[] data)
        {
            int?  userId = data[0];
            float weight = BitConverter.ToInt16(data, 1) / 10.0f;

            // user not specified
            if (userId == 0)
            {
                userId = FindUserBasedOnHistory(ctx, weight);
            }

            if (userId == null)
            {
                _log.Error("Could not find user based on weight '" + weight + "'");
                return;
            }

            _log.Info("Weight received for user [" + userId + "]: " + weight);

            WirelessScaleData wirelessScaleData = new WirelessScaleData
            {
                UserId           = userId.Value,
                Value            = weight,
                ZigBeeDevice     = device,
                ReceivedDateTime = DateTime.Now
            };

            ctx.DbCtx.WirelessScaleDatas.AddObject(wirelessScaleData);
            ctx.DbCtx.SaveChanges();
        }
Beispiel #3
0
 public ActionResult Detail(int id)
 {
     using (ZigBeeCoordinatorContext ctx = new ZigBeeCoordinatorContext())
     {
         ZigBeeDevice device = ctx.DbCtx.ZigBeeDevices
                               .Include(d => d.ZigBeeDeviceType)
                               .Include(d => d.Capabilities)
                               .FirstOrDefault(d => d.ZigBeeDeviceId == id);
         ctx.DbCtx.LoadProperty(device, d => d.ZigBeeDeviceLogs);
         return(View(device));
     }
 }
Beispiel #4
0
 private bool SetDresdenElektronikDevice()
 {
     m_testedDevice   = null;
     m_testedEndPoint = null;
     if (m_zigBeeAdapter.DeviceList.TryGetValue(DRESDEN_ELEKTRONIK_BALLAST_MAC_ADDRESS, out m_testedDevice) &&
         m_testedDevice.EndPointList.TryGetValue(DRESDEN_ELEKTRONIK_BALLAST_END_POINT, out m_testedEndPoint))
     {
         Debug.WriteLine("End point: {0} - {1} - Mac address: 0x{2:X}, Id: 0x{3:X2}, ZigBee profile 0x{4:X4}",
                         m_testedEndPoint.Vendor, m_testedEndPoint.Model, m_testedDevice.MacAddress, m_testedEndPoint.Id, m_testedEndPoint.CommandProfileId);
         return(true);
     }
     else
     {
         return(false);
     }
 }
 /**
  * Instantiates a new ZigBee Network object.
  *
  * @param device Local ZigBee device to get the network from.
  *
  * @throws ArgumentNullException if {@code device == null}.
  *
  * @see ZigBeeDevice
  */
 public ZigBeeNetwork(ZigBeeDevice device)
     : base(device)
 {
 }
Beispiel #6
0
 /**
  * Instantiates a new ZigBee Network object.
  *
  * @param device Local ZigBee device to get the network from.
  *
  * @throws ArgumentNullException if {@code device == null}.
  *
  * @see ZigBeeDevice
  */
 public ZigBeeNetwork(ZigBeeDevice device)
     : base(device)
 {
 }
 public abstract void ProcessData(ZigBeeCoordinatorContext ctx, ZigBeeDevice device, byte[] data);