Reputation: 6187
I am working on a project to integrate light bulb controls using LifX. I tested out on the official Lifx app, it can scan on nearby lightbulbs that hasn't been added on its signed on account before. I would like to do the same. The most promising library I came across (besides tons of others that I tried) is LibxNet, its fairly easy to use and is somewhat the most popular one.
client = await LifxNet.LifxClient.CreateAsync();
client.DeviceDiscovered += Client_DeviceDiscovered;
client.DeviceLost += Client_DeviceLost;
client.StartDeviceDiscovery();
...
private async void Client_DeviceDiscovered(object sender, LifxNet.LifxClient.DeviceDiscoveryEventArgs e)
{
var bulb = e.Device as LifxNet.LightBulb;
await client.SetDevicePowerStateAsync(bulb, true); //Turn bulb on
await client.SetColorAsync(bulb, Colors.Red, 2700); //Set color to Red and 2700K Temperature
}
Unfortunately, best of my integration, I cannot get it to work for Xamarin Forms using the implementation of this nuget library.
I already added necessary permissions which is the same as the official LifX app.
<uses-permission
android:name="android.permission.INTERNET"/>
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission
android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission
android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
The official documentation doesn't really give much as it only says UDP stuffs which I am not even familiar with. Please help me out. Thank you.
Upvotes: 0
Views: 76