Simplest .NETapplication for a Tizen based TV to turn Bluetooth on or off

57 Views Asked by At

Some Tizen based TVs have no interface to turn bluetooth off/on, as explained here. Accessing a menu that is only for use by authorized engineers is not an acceptable solution. Tizen OS allows accessing bluetooth settings programatically.

http://tizen.org/privilege/bluetooth

Allows the application to change Bluetooth settings, such as turning Bluetooth on or off, setting the device name, and enabling or disabling AV remote control.

Type: Native / Dotnet Level: Platform Privacy: No

I can't find a code snippet that is enough to do just this, anything I found is for Windows, and Tizen is Linux. Can you help me adapt the code below?

using System;
using Windows.Devices.Bluetooth;
using Windows.Devices.Radios;

class Program
{
    static async void Main(string[] args)
    {
        var radios = await Radio.GetRadiosAsync();
        var bluetooth = radios.FirstOrDefault(radio => radio.Kind == RadioKind.Bluetooth);
        
        if (bluetooth != null)
        {
            if (bluetooth.State == RadioState.On)
            {
                // Bluetooth is already enabled, turn it off
                await bluetooth.SetStateAsync(RadioState.Off);
                Console.WriteLine("Bluetooth turned off");
            }
            else
            {
                // Bluetooth is currently off, turn it on
                await bluetooth.SetStateAsync(RadioState.On);
                Console.WriteLine("Bluetooth turned on");
            }
        }
        else
        {
            Console.WriteLine("Bluetooth is not available on this device");
        }
    }
}
0

There are 0 best solutions below