Smdn.TPSmartHomeDevices.MacAddressEndPoint 1.1.0

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package Smdn.TPSmartHomeDevices.MacAddressEndPoint --version 1.1.0
NuGet\Install-Package Smdn.TPSmartHomeDevices.MacAddressEndPoint -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Smdn.TPSmartHomeDevices.MacAddressEndPoint" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Smdn.TPSmartHomeDevices.MacAddressEndPoint --version 1.1.0
#r "nuget: Smdn.TPSmartHomeDevices.MacAddressEndPoint, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Smdn.TPSmartHomeDevices.MacAddressEndPoint as a Cake Addin
#addin nuget:?package=Smdn.TPSmartHomeDevices.MacAddressEndPoint&version=1.1.0

// Install Smdn.TPSmartHomeDevices.MacAddressEndPoint as a Cake Tool
#tool nuget:?package=Smdn.TPSmartHomeDevices.MacAddressEndPoint&version=1.1.0

Smdn.TPSmartHomeDevices.MacAddressEndPoint 1.1.0

Smdn.TPSmartHomeDevices.MacAddressEndPoint is an extension library for the Smdn.TPSmartHomeDevices.Tapo and Smdn.TPSmartHomeDevices.Kasa that enables to use MAC addresses to specify the device endpoints, instead of IP addresses or host names.

This library also enables to support following changes of the device endpoint in network where IP addresses are dynamic, such as networks using DHCP.

Usage

Add MacAddressDeviceEndPointFactory to the ServiceCollection and pass it as an IServiceProvider to the constructor of the Tapo or Kasa device class.

using System.Net.NetworkInformation;
using Microsoft.Extensions.DependencyInjection;
using Smdn.Net;
using Smdn.TPSmartHomeDevices;
using Smdn.TPSmartHomeDevices.Tapo;

var services = new ServiceCollection();

// By creating a MacAddressDeviceEndPointFactory and adding it with the
// AddDeviceEndPointFactory method, you can enable MAC address endpoint resolution.
// This can be applied to Kasa devices as well as Tapo devices.
services.AddDeviceEndPointFactory(
  new MacAddressDeviceEndPointFactory(
    // Select and use the network of the interface with ID 'wlan0'
    IPNetworkProfile.CreateFromNetworkInterface(id: "wlan0")
  )
);

var serviceProvider = services.BuildServiceProvider();

// Creates device controller for Tapo L530 multicolor light bulb.
using var bulb = new L530(
  PhysicalAddress.Parse("00:00:5E:00:53:00"), // MAC address assigned to L530
  "user@mail.test", // E-mail address for your Tapo account
  "password",       // Password for your Tapo account
  serviceProvider   // IServiceProvider that has a MacAddressDeviceEndPointFactory added
);

try {
  // Turns on the bulb, and set the color temperature and brightness.
  await bulb.SetColorTemperatureAsync(colorTemperature: 5500, brightness: 80);

  // Turns off the bulb
  await bulb.TurnOffAsync();
}
catch (DeviceEndPointResolutionException ex) {
  // If the endpoint cannot be resolved, a DeviceEndPointResolutionException is thrown.
  Console.Error.WriteLine(ex);

  // In this example, address resolution is based on information cached in the
  // system's address table (ARP table).
  // If there is no IP address corresponding to the MAC address in the cache,
  // address resolution will fail.

  // The MacAddressResolver that MacAddressDeviceEndPointFactory uses internally
  // supports network scanning to perform address table updates prior to address resolution.

  // Documents for enabling network scanning with the MacAddressDeviceEndPointFactory
  // will be added in the future.

  // In MacAddressResolver, network scanning can be enabled by setting the
  // properties NetworkScanInterval and NetworkScanMinInterval.
  // See the MacAddressResolver documentation for detail.
  // https://github.com/smdn/Smdn.Net.AddressResolution/blob/main/examples/network-scanning/Program.cs
}

More examples can be found on the GitHub repository.

Contributing

This project welcomes contributions, feedbacks and suggestions. You can contribute to this project by submitting Issues or Pull Requests on the GitHub repository.

Notice

License

This project is licensed under the terms of the MIT License.

Disclaimer

(An English translation for the reference follows the text written in Japanese.)

本プロジェクトは、TP-Linkとは無関係の非公式なものです。

This is an unofficial project that has no affiliation with TP-Link.

本プロジェクトが提供するソフトウェアは、デバイスの設定の取得・変更等、製品仕様の範囲内での操作のみを行うものであり、ファームウェアの改変・修正および製品の改造や製品仕様の変更を引き起こさないものの、製品使用上の許諾事項に抵触する可能性は否定できないため、使用の際はその点にご留意ください。

The software provided by this project is intended only for operations within the scope of the product specifications, such as acquiring and changing device settings, and while it does not cause altering the product itself, product's firmware or operating specifications. Nevertheless, please note that the possibility of violating terms of use of the product cannot be dismissed when using the software provided by this project.

TapoKasa、および各製品名の著作権はTP-Linkに帰属します。

Tapo, Kasa and all respective product names are copyright of TP-Link.

Credit

This project incorporates implementations partially ported from the following projects. See also ThirdPartyNotices.md for detail.

API List

List of APIs exposed by assembly Smdn.TPSmartHomeDevices.MacAddressEndPoint-1.1.0 (net7.0)

// Smdn.TPSmartHomeDevices.MacAddressEndPoint.dll (Smdn.TPSmartHomeDevices.MacAddressEndPoint-1.1.0)
//   Name: Smdn.TPSmartHomeDevices.MacAddressEndPoint
//   AssemblyVersion: 1.1.0.0
//   InformationalVersion: 1.1.0+26b3994b9e663ddd0b4c39b0a86948a876d03dad
//   TargetFramework: .NETCoreApp,Version=v7.0
//   Configuration: Release
//   Referenced assemblies:
//     Smdn.Net.AddressResolution, Version=1.0.0.0, Culture=neutral
//     Smdn.TPSmartHomeDevices.Primitives, Version=1.0.0.0, Culture=neutral
//     System.ComponentModel, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
//     System.Net.NetworkInformation, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
//     System.Net.Primitives, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
//     System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
#nullable enable annotations

using System;
using System.Net;
using System.Net.NetworkInformation;
using System.Threading;
using System.Threading.Tasks;
using Smdn.Net;
using Smdn.Net.AddressResolution;
using Smdn.TPSmartHomeDevices;

namespace Smdn.TPSmartHomeDevices {
  public class MacAddressDeviceEndPointFactory :
    IDeviceEndPointFactory<PhysicalAddress>,
    IDisposable
  {
    protected class MacAddressDeviceEndPoint : IDynamicDeviceEndPoint {
      public MacAddressDeviceEndPoint(IAddressResolver<PhysicalAddress, IPAddress> resolver, PhysicalAddress address) {}

      public void Invalidate() {}
      public async ValueTask<EndPoint?> ResolveAsync(CancellationToken cancellationToken) {}
      public override string ToString() {}
    }

    [Obsolete("Use an overload that specifies the parameter `shouldDisposeResolver`.")]
    protected MacAddressDeviceEndPointFactory(IAddressResolver<PhysicalAddress, IPAddress> resolver, IServiceProvider? serviceProvider = null) {}
    protected MacAddressDeviceEndPointFactory(IAddressResolver<PhysicalAddress, IPAddress> resolver, bool shouldDisposeResolver, IServiceProvider? serviceProvider) {}
    public MacAddressDeviceEndPointFactory(IPNetworkProfile networkProfile, IServiceProvider? serviceProvider = null) {}
    public MacAddressDeviceEndPointFactory(IPNetworkProfile networkProfile, TimeSpan networkScanInterval, TimeSpan networkScanMinInterval, IServiceProvider? serviceProvider = null) {}
    [Obsolete("Use an overload that specifies the parameter `shouldDisposeResolver`.")]
    public MacAddressDeviceEndPointFactory(MacAddressResolverBase resolver, IServiceProvider? serviceProvider = null) {}
    public MacAddressDeviceEndPointFactory(MacAddressResolverBase resolver, bool shouldDisposeResolver, IServiceProvider? serviceProvider = null) {}

    public virtual IDeviceEndPoint Create(PhysicalAddress address) {}
    protected virtual void Dispose(bool disposing) {}
    public void Dispose() {}
    protected void ThrowIfDisposed() {}
  }
}
// API list generated by Smdn.Reflection.ReverseGenerating.ListApi.MSBuild.Tasks v1.2.2.0.
// Smdn.Reflection.ReverseGenerating.ListApi.Core v1.2.0.0 (https://github.com/smdn/Smdn.Reflection.ReverseGenerating)
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Smdn.TPSmartHomeDevices.MacAddressEndPoint:

Package Downloads
Smdn.TPSmartHomeDevices The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org.

A meta package that addes the dependency of Smdn.TPSmartHomeDevices.Kasa, Smdn.TPSmartHomeDevices.Tapo and Smdn.TPSmartHomeDevices.MacAddressEndPoint.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0 168 5/14/2023
1.0.0 234 5/2/2023
1.0.0-rc1 198 4/27/2023