Comments (12)
You need to advertise a BLE service with these parameters:
- Service UUID =
fe 2c
- Service data =
fc 12 8e 01 42 00 00 00 00 00 00 00 00 00 [10 random bytes]
If you're using win32 APIs, this looks like a good starting point (it's unreasonably messy though).
For UWP/WinRT, use this.
(sorry, I'm too lazy to set up Visual Studio on my VM to provide you with a minimal working code example for this specific case)
from neardrop.
Thank you, @grishka!
I have broadcasted a BLE service as you have suggested, but the Android device is still not discoverable until I fire the Activity Intent or use an older version of the Google Files app and tap "receive".
Can you please tell me if I am missing something here? Thank you!
` public sealed class BLEAdvertisementService
{
private BluetoothLEAdvertisementWatcher watcher;
private BluetoothLEAdvertisementPublisher publisher;
// Service UUID: fe2c
private const string ServiceUuid = "0000fe2c-0000-1000-8000-00805f9b34fb";
// Service Data: fc 12 8e 01 42 00 00 00 00 00 00 00 00 00 [10 random bytes]
private readonly byte[] serviceData = { 0xFC, 0x12, 0x8E, 0x01, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
public void StartAdvertising()
{
publisher = new BluetoothLEAdvertisementPublisher();
// Create the service data section of the advertisement
var serviceDataSection = new BluetoothLEAdvertisementDataSection();
var writer = new DataWriter();
writer.WriteBytes(serviceData);
serviceDataSection.Data = writer.DetachBuffer();
// Add the service data section to the advertisement
publisher.Advertisement.DataSections.Add(serviceDataSection);
// Set the UUIDs of the services being advertised
publisher.Advertisement.ServiceUuids.Add(new Guid(ServiceUuid));
// Start advertising
publisher.Start();
}
public void StopAdvertising()
{
publisher?.Stop();
publisher = null;
}
}`
from neardrop.
You need to append 10 random bytes to the service data.
from neardrop.
Excuse my naivety here. Can you please explain what the service data should be? Is it any random 10 bytes? Or should I append 10 random bytes to the service data that you have already given - fc 12 8e 01 42 00 00 00 00 00 00 00 00 00
from neardrop.
Yes, to the one I already given
from neardrop.
Thank you, @grishka! Can you please tell me if I can run this BLE service as a separate process (independent of my actual UWP app) for now? I have a few build issues with my UWP app as of now. I want to quickly establish if the whole approach works for me.
And in case you have a publicly available Windows equivalent of this project of yours, it would be a great inspiration to me!
from neardrop.
You can. It doesn't matter which process you run it in, that doesn't change the broadcasts that go out. I was able to make them with "nRF Connect" Android app, for example. That app is also how I determined the format.
from neardrop.
Hello @grishka,
Despite broadcasting the said signal, my Android device is still not visible without using an older version of the Google Files app and tapping "receive".
Here is my broadcast code:
namespace App1.Source
{
using System;
using Windows.Devices.Bluetooth.Advertisement;
using Windows.Storage.Streams;
public sealed class BLEAdvertisementService
{
private BluetoothLEAdvertisementPublisher publisher;
private string serviceUuid = "0000fe2c-0000-1000-8000-00805f9b34fb";
private byte[] serviceData = { 0xFC, 0x12, 0x8E, 0x01, 0x42, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x40 };
public void StartAdvertising()
{
publisher = new BluetoothLEAdvertisementPublisher();
// Create the service data section of the advertisement
var serviceDataSection = new BluetoothLEAdvertisementDataSection();
var writer = new DataWriter();
writer.WriteBytes(serviceData);
serviceDataSection.Data = writer.DetachBuffer();
// Add the service data section to the advertisement
publisher.Advertisement.DataSections.Add(serviceDataSection);
// Set the UUIDs of the services being advertised - NOT WORKING
//publisher.Advertisement.ServiceUuids.Add(new Guid(serviceUuid));
// Start advertising
publisher.Start();
}
public void StopAdvertising()
{
publisher?.Stop();
publisher = null;
}
}
}
Edit: @grishka, if I set the serviceUuid, then I see an exception "Value does not fall within the expected range" when the publisher starts. I tried to understand the significance of Service Uuid and the Service Data, but I am just getting started.
Any help from your end to correctly broadcast would be critical in me succeeding with this project!
Thanks a lot!
from neardrop.
Hello @grishka, hope you are doing great! I spent some more time debugging my code and gained a deeper understanding. Updated my previous question. Please consider responding when feasible.
from neardrop.
Hello @grishka, hope you are doing great! Looking forward to your inputs in fixing this.
Thanks a lot!
from neardrop.
Related Issues (20)
- SwiftProtobuf.BinaryDecodingError error 3. Failed to receive file
- SwiftProtobuf.BinaryDecodingError error 3. Failed to receive file HOT 2
- Quick Share support? HOT 53
- Stops working after the first share. Android -> Mac HOT 1
- How to Implementing Nearby Connection SDK in Android
- Macbook not showing in android's nearby share option HOT 4
- Android device not visible on mac after new google file update HOT 17
- Donation options? HOT 2
- Neardrop not working with Samsung devices
- Android not available when sharing from Mac HOT 2
- not working anymore, after the release of quickshare HOT 9
- Not working after the update of Quick Share. HOT 20
- Can't send from Mac to a Samsung device after the Quick Share update HOT 22
- The google file app removed shortcut to nearby sharing HOT 10
- Communication error: Transferring files from Samsung to Mac by using Quick Share HOT 28
- Not Working in Catalina - 10.15.7 (19H15) HOT 1
- Same "Communication Error" HOT 2
- Cannot send from SamSung S23 to Mac HOT 3
- Neardrop disappearsl quickly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neardrop.