Esempio n. 1
0
        // Save device in memory at discovery
        private async void Client_DeviceDiscoveredAsync(object sender, LifxClient.DeviceDiscoveryEventArgs e)
        {
            var bulb  = e.Device as LightBulb;
            var label = await client.GetDeviceLabelAsync(e.Device);

            await context.Bulbs.AddAsync(bulb);
        }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        var task = LifxClient.CreateAsync();

        task.Wait();
        Client = task.Result;
        Client.DeviceDiscovered += Client_DeviceDiscovered;
        Client.DeviceLost       += Client_DeviceLost;
        Client.StartDeviceDiscovery();

        // Print the label of each device
        Client.Devices.ToList().ForEach(device => Debug.Log(Client.GetDeviceLabelAsync(device)));

        // MIDI IN 4
        OpenMidiDevice(
            Tuple.Create("MIDIIN4 (mio4)", 10)
            );
    }
        async void _client_DeviceDiscovered(object sender, LifxClient.DeviceDiscoveryEventArgs e)
        {
            LightBulb bulb = e.Device as LightBulb;

            if (!_bulbs.Contains(bulb))
            {
                _bulbs.Add(bulb);

                LifxDevice device = new LifxDevice
                {
                    MacAddressName = bulb.MacAddressName
                };

                device.Label = await _client.GetDeviceLabelAsync(bulb);

                if (device.Label == _initLabel && _selected == null)
                {
                    _selected = device;
                }
                _devices.Add(device);
            }
        }
Esempio n. 4
0
 private static IEnumerator LogDeviceName(LifxClient.DeviceDiscoveryEventArgs e)
 {
     Debug.Log("Light: " + Client.GetDeviceLabelAsync(e.Device).Id);
     yield return(null);
 }