-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Description
using System;
using InTheHand.Net.Sockets;
using InTheHand.Net.Bluetooth;
using System.IO;
class Program
{
static void Main(string[] args)
{
string deviceAddress = "00:11:22:33:44:55"; // Address MAC From the device Bluetooth
Guid serviceUuid = new Guid("00001101-0000-1000-8000-00805F9B34FB"); // UUID From the service Bluetooth
try
{
BluetoothAddress address = BluetoothAddress.Parse(deviceAddress);
BluetoothClient client = new BluetoothClient();
client.Connect(new BluetoothEndPoint(address, serviceUuid));
using (NetworkStream stream = client.GetStream())
using (StreamWriter writer = new StreamWriter(stream))
using (StreamReader reader = new StreamReader(stream))
{
// Send command to open the lock
writer.WriteLine("OPEN"); // O specific command depends on the device
writer.Flush();
// Read response from device
string response = reader.ReadLine();
Console.WriteLine("Response: " + response);
}
client.Close();
}
catch (Exception ex)
{
Console.WriteLine("Error: " + ex.Message);
}
}
}
Metadata
Metadata
Assignees
Labels
No labels