Skip to content

Commit fc7fe8d

Browse files
committed
Working on adding also Bluetooth events #32
1 parent b0a6ba8 commit fc7fe8d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+25211
-6431
lines changed

NL.HNOGames.Domoticz/NL.HNOGames.Domoticz.Android/NL.HNOGames.Domoticz.Android.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2202,6 +2202,9 @@
22022202
<PackageReference Include="Shiny.Beacons">
22032203
<Version>1.1.0.1473-beta</Version>
22042204
</PackageReference>
2205+
<PackageReference Include="Shiny.BluetoothLE">
2206+
<Version>1.1.0.1473-beta</Version>
2207+
</PackageReference>
22052208
<PackageReference Include="Shiny.Core">
22062209
<Version>1.1.0.1473</Version>
22072210
</PackageReference>

NL.HNOGames.Domoticz/NL.HNOGames.Domoticz.iOS/Info.plist

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
<array>
3131
<string>location</string>
3232
<string>remote-notification</string>
33+
<string>bluetooth-central</string>
34+
<string>bluetooth-peripheral</string>
3335
</array>
3436
<key>UIRequiresFullScreen</key>
3537
<string>YES</string>
@@ -61,6 +63,10 @@
6163
<string>We need the microphone for speech recognition</string>
6264
<key>NSFaceIDUsageDescription</key>
6365
<string>Need your face to unlock Domoticz.</string>
66+
<key>NSBluetoothPeripheralUsageDescription</key>
67+
<string>You can set switches automaticly on Bluetooth connections</string>
68+
<key>NSBluetoothAlwaysUsageDescription</key>
69+
<string>You can set switches automaticly on Bluetooth connections</string>
6470
<key>NSAppTransportSecurity</key>
6571
<dict>
6672
<key>NSAllowsArbitraryLoads</key>

NL.HNOGames.Domoticz/NL.HNOGames.Domoticz.iOS/NL.HNOGames.Domoticz.iOS.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,9 @@
814814
<PackageReference Include="Shiny.Beacons">
815815
<Version>1.1.0.1473-beta</Version>
816816
</PackageReference>
817+
<PackageReference Include="Shiny.BluetoothLE">
818+
<Version>1.1.0.1473-beta</Version>
819+
</PackageReference>
817820
<PackageReference Include="Shiny.Core">
818821
<Version>1.1.0.1473</Version>
819822
</PackageReference>

NL.HNOGames.Domoticz/NL.HNOGames.Domoticz/Helpers/Settings.cs

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ public class Settings
116116
/// </summary>
117117
private const string SpeechSettingsKey = "speech_settings_key2";
118118

119+
/// <summary>
120+
/// Defines the BluetoothSettingsKey
121+
/// </summary>
122+
private const string BluetoothSettingsKey = "bluetooth_settings_key";
123+
124+
/// <summary>
125+
/// Defines the EnableBluetoothSettingsKey
126+
/// </summary>
127+
private const string EnableBluetoothNotificationsSettingsKey = "enable_bluetooth_notifications_settings_key";
128+
129+
/// <summary>
130+
/// Defines the EnableBluetoothSettingsKey
131+
/// </summary>
132+
private const string EnableBluetoothSettingsKey = "enable_bluetooth_settings_key";
133+
119134
/// <summary>
120135
/// Defines the BeaconSettingsKey
121136
/// </summary>
@@ -508,6 +523,68 @@ public bool GeofenceEnabled
508523
}
509524
}
510525

526+
/// <summary>
527+
/// Gets or sets a value indicating whether BluetoothEnabled
528+
/// Enable the Bluetooth feature
529+
/// </summary>
530+
public bool BluetoothEnabled
531+
{
532+
get
533+
{
534+
return AppSettings.GetValueOrDefault(EnableBluetoothSettingsKey, false);
535+
}
536+
set
537+
{
538+
AppSettings.AddOrUpdateValue(EnableBluetoothSettingsKey, value);
539+
}
540+
}
541+
542+
/// <summary>
543+
/// Gets or sets a value indicating whether BluetoothEnabled
544+
/// Enable the Bluetooth feature
545+
/// </summary>
546+
public bool BluetoothNotificationsEnabled
547+
{
548+
get
549+
{
550+
return AppSettings.GetValueOrDefault(EnableBluetoothNotificationsSettingsKey, false);
551+
}
552+
set
553+
{
554+
AppSettings.AddOrUpdateValue(EnableBluetoothNotificationsSettingsKey, value);
555+
}
556+
}
557+
558+
/// <summary>
559+
/// Gets or sets the Bluetooths
560+
/// Specify Bluetooth models
561+
/// </summary>
562+
public List<BluetoothModel> Bluetooths
563+
{
564+
get
565+
{
566+
try
567+
{
568+
String resultCache = AppSettings.GetValueOrDefault(BluetoothSettingsKey, string.Empty);
569+
if (!string.IsNullOrEmpty(resultCache))
570+
{
571+
var value = JsonConvert.DeserializeObject<List<BluetoothModel>>(resultCache);
572+
return value;
573+
}
574+
else
575+
return new List<BluetoothModel>();
576+
}
577+
catch (Exception) { }
578+
return new List<BluetoothModel>();
579+
}
580+
set
581+
{
582+
if (value == null)
583+
return;
584+
AppSettings.AddOrUpdateValue(BluetoothSettingsKey, JsonConvert.SerializeObject(value));
585+
}
586+
}
587+
511588
/// <summary>
512589
/// Gets or sets a value indicating whether BeaconEnabled
513590
/// Enable the Beacon feature
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
using NL.HNOGames.Domoticz.Resources;
2+
using System;
3+
4+
namespace NL.HNOGames.Domoticz.Models
5+
{
6+
/// <summary>
7+
/// Defines the <see cref="BluetoothModel" />
8+
/// </summary>
9+
public class BluetoothModel
10+
{
11+
#region Properties
12+
13+
/// <summary>
14+
/// Gets or sets a value indicating whether Enabled
15+
/// </summary>
16+
public bool Enabled { get; set; }
17+
18+
/// <summary>
19+
/// Gets or sets a value indicating whether IsScene
20+
/// </summary>
21+
public bool IsScene { get; set; }
22+
23+
/// <summary>
24+
/// Gets or sets the Id
25+
/// </summary>
26+
public string Id { get; set; }
27+
28+
/// <summary>
29+
/// Gets or sets the Name
30+
/// </summary>
31+
public string Name { get; set; }
32+
33+
/// <summary>
34+
/// Gets or sets the SwitchIDX
35+
/// </summary>
36+
public string SwitchIDX { get; set; }
37+
38+
/// <summary>
39+
/// Gets or sets the SwitchName
40+
/// </summary>
41+
public string SwitchName { get; set; }
42+
43+
/// <summary>
44+
/// Gets or sets the SwitchPassword
45+
/// </summary>
46+
public string SwitchPassword { get; set; }
47+
48+
/// <summary>
49+
/// Gets or sets the Value
50+
/// </summary>
51+
public string Value { get; set; }
52+
53+
/// <summary>
54+
/// Gets the SwitchDescription
55+
/// </summary>
56+
public string SwitchDescription
57+
{
58+
get
59+
{
60+
return string.IsNullOrEmpty(SwitchName) ? AppResources.connectedSwitch + ": -" : AppResources.connectedSwitch + ": " + SwitchName;
61+
}
62+
}
63+
64+
#endregion
65+
}
66+
}

NL.HNOGames.Domoticz/NL.HNOGames.Domoticz/NL.HNOGames.Domoticz.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)