/// <summary>
        /// Handle a 'Remove allowed device' response.
        /// </summary>
        /// <param name="packet">The packet to check.</param>
        private void HandleRemoveAllowedResponse(CommandData packet)
        {
            try
            {
                Beacon receivedBeacon = RiderIDCommandDataParser.ParseAllowedDeviceOperationResponse(packet.Status, packet.Data);

                if (packet.Status == 0)
                {
                    Log.Info($"{this.unitId}: Succesfully removed Beacon {receivedBeacon}");
                    this.knownRiders.RemoveAll(rid => rid.Beacon.Equals(receivedBeacon));
                }
                else
                {
                    switch (packet.Status)
                    {
                    case (ushort)0xFFFFU:
                        Log.Warn($"{this.unitId}: Failure while removing rider with beacon {receivedBeacon}, device not found");
                        break;

                    default:
                        Log.Warn($"{this.unitId}: Failure while removing rider, got packet status {packet.Status}");
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error($"{this.unitId}: Received bad response for {packet.CommandType} command", ex);
            }
        }
        /// <summary>
        /// Handle a 'Add allowed device' response.
        /// </summary>
        /// <param name="packet">The packet to check.</param>
        private void HandleAddAllowedResponse(CommandData packet)
        {
            try
            {
                Beacon receivedBeacon = RiderIDCommandDataParser.ParseAllowedDeviceOperationResponse(packet.Status, packet.Data);

                if (packet.Status == 0)
                {
                    if (this.knownRiders.Any(rid => rid.Beacon.Equals(receivedBeacon)))
                    {
                        Log.Info($"{this.unitId}: Successfully added rider {this.knownRiders.First(rid => rid.Beacon.Equals(receivedBeacon)).Name} with beacon {receivedBeacon}");
                    }
                    else
                    {
                        Log.Warn($"{this.unitId}: Successfully added beacon {receivedBeacon}, but no rider was found with that beacon. Sending remove command");
                        this.commandQueue.Enqueue(this.GenerateRemoveRiderCommand(receivedBeacon));
                    }
                }
                else
                {
                    switch (packet.Status)
                    {
                    case (ushort)0xFFFFU:
                        Log.Warn($"{this.unitId}: Failure while adding rider with beacon {receivedBeacon}, device already exists");
                        break;

                    case (ushort)0xFFFEU:
                        Log.Warn($"{this.unitId}: Failure while adding rider with beacon {receivedBeacon}, maximum number of devices reached");
                        break;

                    default:
                        Log.Warn($"{this.unitId}: Failure while adding rider, got packet status {packet.Status}");
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error($"{this.unitId}:Received bad response for {packet.CommandType} command", ex);
            }
        }
 /// <summary>
 /// Handle a 'List all allowed devices' response.
 /// </summary>
 /// <param name="packet">The packet to check.</param>
 private void HandleListAllowedDevices(CommandData packet)
 {
     try
     {
         if ((packet.Status == 1) && (packet.Data.Length > 2))
         {
             byte[] beaconData = new byte[packet.Data.Length - 2];
             packet.Data.CopyTo(beaconData, 2);
             this.foundBeacons.AddRange(RiderIDCommandDataParser.ParseClosestDeviceResponse(0, beaconData));
             if (packet.Data[0] == (packet.Data[1] - 1))
             {
                 foreach (Beacon b in this.foundBeacons)
                 {
                     this.commandQueue.Enqueue(this.GenerateRemoveRiderCommand(b));
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Error($"{this.unitId}:Received bad response for {packet.CommandType} command", ex);
     }
 }