OhrTech.Device
0.1.1
dotnet add package OhrTech.Device --version 0.1.1
NuGet\Install-Package OhrTech.Device -Version 0.1.1
<PackageReference Include="OhrTech.Device" Version="0.1.1" />
<PackageVersion Include="OhrTech.Device" Version="0.1.1" />
<PackageReference Include="OhrTech.Device" />
paket add OhrTech.Device --version 0.1.1
#r "nuget: OhrTech.Device, 0.1.1"
#:package OhrTech.Device@0.1.1
#addin nuget:?package=OhrTech.Device&version=0.1.1
#tool nuget:?package=OhrTech.Device&version=0.1.1
OhrTech Device SDK for .NET
OhrTech.Device: what an app on an OhrTech device can ask the OhrTech Agent for, from .NET for Android and .NET MAUI.
Who the device is, the app's own updates, Wi-Fi (with Android's Wi-Fi screen embedded in your layout), mobile data and
airplane mode, kiosk mode, power, settings, managed configuration, KEM keys and attestation in the device's TEE, client
certificates, pre-approved USB devices, its own events and logs, and push from your own server, end to end.
Documentation: https://docs.ohrtech.net/device-sdk/
dotnet add package OhrTech.Device
dotnet add package OhrTech.Device.Maui # MAUI apps: the Wi-Fi screen as a control, UseOhrTechDevice()
net10.0-android, Android 13 (API 33) and up (<SupportedOSPlatformVersion>33</SupportedOSPlatformVersion>), on OhrTech
devices with the OhrTech Agent 1059 or later. Trim- and NativeAOT-safe. It wraps the Kotlin library
(net.ohrtech:device-sdk), so the Agent protocol and its checks are the
same as for Kotlin apps; the binding is internal, and the API is plain C#.
Who may use what
The Agent answers apps your organisation installed through OhrTech; others get OhrNotManagedException. Reading is mostly
always allowed. Changing something needs the fleet's grant for that area, set in the portal under the fleet's apps: wifi,
network, kiosk, power, settings. Settings and networks the fleet locks stay locked (OhrFleetLockedException).
Use
using OhrTech.Device;
var info = await OhrDevice.GetInfoAsync(); // DeviceId "dev_…", fleet, org, OS, Agent
if (await OhrAccess.MayUseAsync("kiosk")) await OhrKiosk.StartAsync(activity);
OhrWifi.StateChanged += OnWifiStateChanged; // raised on the thread that subscribed (the UI thread)
void OnWifiStateChanged(object? sender, OhrWifiStateChangedEventArgs e) => label.Text = e.State.Ssid;
await foreach (var battery in OhrPower.BatteryChanges(cancellationToken)) { … }
Each area is a static class; there is nothing to connect or close. The library binds the Agent on the first call and keeps
the binding; when the Agent stops (a crash, its own update) it binds again, and every event and stream goes on.
OhrDeviceSdk.ConnectionChanged says how it stands.
| Class | |
|---|---|
OhrDevice |
GetInfoAsync(): device id, serial, fleet, org, OS version and patch, Agent version, online |
OhrUpdates |
GetAvailableAsync(), InstallAsync(whenIdle), Changed: the app's own updates the hub offers |
OhrWifi |
state, networks around, saved networks, SaveAsync, ConnectAsync, ForgetAsync, SetEnabledAsync, ConnectQrAsync |
OhrNetwork |
GetStateAsync(), SetMobileDataAsync, SetAirplaneModeAsync, SetDataRoamingAsync |
OhrKiosk |
StartAsync(activity), StopAsync(), GetStateAsync(), RequestExitAsync(), Heartbeat() |
OhrPower |
GetBatteryAsync(), RebootAsync, ScheduleRebootAsync, SetScreenTimeoutAsync, SetBrightnessAsync |
OhrSettings |
GetKeysAsync(), GetAsync(key), SetAsync(key, value): the device settings apps may change |
OhrConfig |
the app's managed configuration, as its fleet or device sets it |
OhrAttestation |
AttestAsync(challenge), GetTokenAsync(audience): proof for your server of this app on this device |
OhrCertificates |
client certificates made on the device or imported; CreateHttpHandler() for HttpClient |
OhrUsb |
the USB devices the fleet pre-approves for the app: no permission prompt |
OhrDiagnostics |
the app's own events and log lines for the hub; crashes are reported without it |
OhrKeys |
TEE KEM keys: ML-KEM, X-Wing, X25519 for HPKE |
OhrPush |
end-to-end push: see below |
Changes come as static events (the first handler watches the Agent, the last one removed stops; remove handlers when a page
goes away, since a static event holds them) and as IAsyncEnumerable streams, ended by their cancellation token. For
dependency injection and test fakes, each area's Current is an interface (IOhrWifi, ...).
Every call can throw an OhrException: OhrNotManagedException, OhrNotAllowedException (Area),
OhrFleetLockedException (Key), OhrUnsupportedException (Reason, NeedsAgent), OhrInvalidConfigException
(Field, Reason), OhrRefusedException or OhrFailedException.
MAUI
builder.UseMauiApp<App>()
.UseOhrTechDevice(o => o.OnPushMessage(OnPushMessage));
<ohr:OhrWifiView xmlns:ohr="clr-namespace:OhrTech.Device.Maui;assembly=OhrTech.Device.Maui"
Connected="OnWifiConnected" Error="OnWifiError" />
The Agent draws Android's Wi-Fi screen inside the control: no other activity or window opens, so a kiosk app stays a kiosk.
In .NET for Android, OhrTech.Device.OhrWifiView is the same as an Android view.
Kiosk heartbeat
OhrKiosk.Heartbeat() beats from Android's main thread, where .NET for Android and MAUI run their UI: if it hangs for longer
than the timeout, the Agent stops the app and starts it again. Call it after OhrKiosk.StartAsync().
Push
Messages from your server, sealed to the device's TEE key and signed by your sender key; the OhrTech hub only carries them.
The library declares the push service; set the handlers when the process starts (UseOhrTechDevice, or your Application's
OnCreate): the Agent starts the app for a message, and the handlers run whether the app is open or not.
OhrPush.SetHandlers(onMessage: async message => { /* message.Data: verified, opened, in date, not seen before */ });
var token = await OhrPush.RegisterAsync([OhrSenderKey.FromBase64(ed25519PublicKey)]);
// Send token.Token and token.PublicKeyBase64 to your server.
Client certificates
The keys stay in the device's Android Keystore, so requests that need the app's client certificate go through Android's TLS:
using var http = new HttpClient(OhrCertificates.CreateHttpHandler("orders"));
var orders = await http.GetStringAsync("https://api.example.com/orders");
It also trusts the private CAs the fleet gives the app.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-android36.0 is compatible. |
-
net10.0-android36.0
- Xamarin.AndroidX.Annotation (>= 1.11.0)
- Xamarin.AndroidX.Startup.StartupRuntime (>= 1.2.0.8)
- Xamarin.Kotlin.StdLib (>= 2.4.0.1)
- Xamarin.KotlinX.Coroutines.Android (>= 1.11.0.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OhrTech.Device:
| Package | Downloads |
|---|---|
|
OhrTech.Device.Maui
The OhrTech Device SDK in .NET MAUI: the Agent's Wi-Fi screen as a MAUI control, and UseOhrTechDevice() for the push handlers and dependency injection. Builds on OhrTech.Device. |
GitHub repositories
This package is not used by any popular GitHub repositories.