Beispiel #1
0
        public void parsePacket(byte[] _data, uint _uDataSize)
        {
            ushort uDeviceId = BitConverter.ToUInt16(_data, 0);
            PGVersion version = new PGVersion(_data, 2);
            byte btPacketType = _data[8];

            System.Diagnostics.Debug.Write("packet, device id:" + uDeviceId + ", type: " + btPacketType + ", version: " + version);
            // TODO: validate packet version!!!
            switch ((Packet.PacketTypes)btPacketType)
            {
                case Packet.PacketTypes.pgLabelInfoPacket:
                        _onPacketEvent(new LabelInfoPacket(uDeviceId, version, _data, _uDataSize), LabelInfoEvent);
                    break;
                case Packet.PacketTypes.pgLabelBroadcastPacket:
                        _onPacketEvent(new LabelBroadcastPacket(uDeviceId, version, _data, _uDataSize), LabelBroadcastEvent);
                    break;
                case Packet.PacketTypes.pgWorkerDeviceLabelPacket:
                    _onPacketEvent(new WorkerDeviceLabelPacket(uDeviceId, version, _data, _uDataSize), WorkerDeviceLabelEvent);
                    break;
                default:
                    return;
            }
        }
Beispiel #2
0
 public LabelBroadcastPacket(ushort _uDeviceId, PGVersion _version, byte[] _data, uint _uPacketSize)
     : base(_version, Packet.PacketTypes.pgLabelBroadcastPacket)
 {
     m_uSourceId = _uDeviceId;
 }
Beispiel #3
0
 public WorkerDeviceLabelPacket(ushort _uDeviceId, PGVersion _version, byte[] _data, uint _uPacketSize)
     : base(_version, Packet.PacketTypes.pgWorkerDeviceLabelPacket)
 {
     m_uDeviceId = _uDeviceId;
     m_uLabelId = BitConverter.ToUInt16(_data, 9);
     m_btSignalPower = _data[11];
     System.Diagnostics.Debug.Write("----WorkerDeviceLabelPacket --"+ m_uDeviceId + ":" + m_uLabelId + ": " + m_btSignalPower + "\n");
 }
Beispiel #4
0
        public WorkerDeviceInfoPacket(ushort _uDeviceId, PGVersion _version, byte[] _data, uint _uPacketSize)
            : base(_version, Packet.PacketTypes.pgWorkerDeviceInfoPacket)
        {
            m_uDeviceId = _uDeviceId;

            m_uBatteryVoltage = BitConverter.ToUInt16(_data, 9);
            m_btCharging = _data[11];
            m_btLabelMinSignalLevel = _data[12];
            m_btLabelObserveTimeoutSec = _data[13];
            System.Diagnostics.Debug.Write("----WorkerDeviceInfoPacket --" + m_uDeviceId + ":" + m_uBatteryVoltage + ": " + m_btCharging + ": " + m_btLabelMinSignalLevel + ": " + m_btLabelObserveTimeoutSec + "\n");
        }
Beispiel #5
0
 protected Packet(PGVersion _version, PacketTypes _type)
 {
     m_version = _version;
     m_type = _type;
 }
Beispiel #6
0
 public LabelInfoPacket(ushort _uDeviceId, PGVersion _version, byte[] _data, uint _uPacketSize)
     : base(_version, Packet.PacketTypes.pgLabelInfoPacket)
 {
     m_uSourceId = _uDeviceId;
     m_uBatteryVoltage = BitConverter.ToUInt16(_data, 9);
     m_btState = _data[11];
 }