public void sendCommand(byte dest, IDataToken input, Module module, byte register, byte id, params byte[] parameters)
            {
                byte[] command = new byte[parameters.Length + 3];
                Array.Copy(parameters, 0, command, 3, parameters.Length);
                command[0] = (byte)module;
                command[1] = register;
                command[2] = id;

                sendCommand(command, dest, input);
            }
            public void sendCommand(byte[] command, byte dest, IDataToken input)
            {
                metawear.persistent.modules.TryGetValue(typeof(Event).FullName, out var module);
                Event eventModule = module as Event;

                DataTypeBase producer = (DataTypeBase)input;

                eventModule.feedbackParams = Tuple.Create(producer.attributes.length(), producer.attributes.offset, dest);
                sendCommand(command);
                eventModule.feedbackParams = null;
            }
Esempio n. 3
0
        public void Configure(Guid?uuid             = default(Guid?), ushort?major   = default(ushort?), ushort?minor = default(ushort?),
                              IDataToken majorToken = null, IDataToken minorToken    = null,
                              sbyte?txPower         = default(sbyte?), sbyte?rxPower = default(sbyte?),
                              ushort?period         = default(ushort?))
        {
            if (uuid != null)
            {
                byte[] guidBytes = uuid.Value.ToByteArray();

                // Implementation taken from SO: http://stackoverflow.com/a/16722909
                Array.Reverse(guidBytes, 0, 4);
                Array.Reverse(guidBytes, 4, 2);
                Array.Reverse(guidBytes, 6, 2);
                Array.Reverse(guidBytes);

                bridge.sendCommand(IBEACON, AD_UUID, guidBytes);
            }

            if (major != null)
            {
                bridge.sendCommand(IBEACON, MAJOR, Util.ushortToBytesLe(major.Value));
            }
            else if (majorToken != null)
            {
                bridge.sendCommand(new byte[] { (byte)IBEACON, MAJOR, 0x0, 0x0 }, 0, majorToken);
            }

            if (minor != null)
            {
                bridge.sendCommand(IBEACON, MINOR, Util.ushortToBytesLe(minor.Value));
            }
            else if (minorToken != null)
            {
                bridge.sendCommand(new byte[] { (byte)IBEACON, MINOR, 0x0, 0x0 }, 0, minorToken);
            }

            if (rxPower != null)
            {
                bridge.sendCommand(new byte[] { (byte)IBEACON, RX, (byte)rxPower.Value });
            }

            if (txPower != null)
            {
                bridge.sendCommand(new byte[] { (byte)IBEACON, TX, (byte)txPower.Value });
            }

            if (period != null)
            {
                bridge.sendCommand(IBEACON, PERIOD, Util.ushortToBytesLe(period.Value));
            }
        }
Esempio n. 4
0
 public void SetMinor(IDataToken minor)
 {
     bridge.sendCommand(new byte[] { (byte)IBEACON, MINOR, 0x0, 0x0 }, 0, minor);
 }
Esempio n. 5
0
 public void SetMajor(IDataToken major)
 {
     bridge.sendCommand(new byte[] { (byte)IBEACON, MAJOR, 0x0, 0x0 }, 0, major);
 }