Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the ability to set a company UUID. #589

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions Source/Meadow.Core/Gateways/Bluetooth/Definitions/Definition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ public class Definition : IDefinition
/// </summary>
public string DeviceName { get; }

/// <summary>
/// Gets the company ID.
/// </summary>
public short? CompanyId { get; }

/// <summary>
/// Gets the collection of services associated with this device definition.
/// </summary>
Expand All @@ -23,6 +28,21 @@ public class Definition : IDefinition
public Definition(string deviceName, params IService[] services)
{
DeviceName = deviceName;
CompanyId = null;
Services = new ServiceCollection();
Services.AddRange(services);
}

/// <summary>
/// Initializes a new instance of the <see cref="Definition"/> class with the specified device name and services.
/// </summary>
/// <param name="companyId">The company ID (assigned number).</param>
/// <param name="deviceName">The name of the device.</param>
/// <param name="services">The services associated with the device.</param>
public Definition(short companyId, string deviceName, params IService[] services)
{
DeviceName = deviceName;
CompanyId = companyId;
Services = new ServiceCollection();
Services.AddRange(services);
}
Expand All @@ -38,6 +58,11 @@ public string ToJson()
""deviceName"":""{DeviceName}""
";

if (CompanyId != null)
{
json += $@", ""companyIdentifier"":{CompanyId}";
}

if (Services != null && Services.Count > 0)
{
json += ", \"services\": [";
Expand Down
Loading