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

Cannot apply ServiceRecord #443

Open
Taro7x3 opened this issue Nov 29, 2024 · 3 comments
Open

Cannot apply ServiceRecord #443

Taro7x3 opened this issue Nov 29, 2024 · 3 comments

Comments

@Taro7x3
Copy link

Taro7x3 commented Nov 29, 2024

Service records created using ServiceRecordBuilder(); cannot be applied to BluetoothListener.ServiceRecord.

var serviceClass = new Guid("00001101-0000-1000-8000-00805F9B34FB");
var serviceName = "Virtual Printer";

var builder = new ServiceRecordBuilder();

builder.AddServiceClass(BluetoothService.SerialPort);
builder.AddServiceClass(BluetoothService.BasicPrinting);
builder.AddServiceClass(BluetoothService.PrintingStatus);
builder.ServiceName = serviceName;

builder.AddCustomAttribute(new ServiceAttribute(0x0304,
    ServiceElement.CreateNumericalServiceElement(ElementType.UInt16, 0x0001)));

ServiceRecord record = builder.ServiceRecord;

listener = new BluetoothListener(serviceClass) 
{
    ServiceRecord = record
};

var radio = BluetoothRadio.PrimaryRadio;
if (radio != null)
{
    radio.Mode = RadioMode.Discoverable;
}

listener.Start();
@peterfoot
Copy link
Member

peterfoot commented Dec 3, 2024

Are you getting an error, or not seeing the device advertising those details? Also what platform are you running this on?

@Taro7x3
Copy link
Author

Taro7x3 commented Dec 3, 2024

The "ServiceRecord (BluetoothListener.ServiceRecord)" is Read Only, so I couldn't access or create instance with original service record that I built with "ServiceRecordBuilder".
Is there any way to apply custmized Service Record to BluetoothListener?

My project is based on WPF (Visual Studio 2022, .Net 9.0) and using 32feet.NET (3.5.0).

@peterfoot
Copy link
Member

I see, there is a specific constructor which accepts a service record - public BluetoothListener(Guid service, ServiceRecord sdpRecord)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants