Android Nearby Share compatibility with Windows Nearby Connections #2446
Replies: 25 comments
-
Hey @rajendrasp, glad to hear you were able to get Nearby Connections building/running on Windows, that’s awesome! In order to discover Android devices running Nearby Share on Windows, you’d need to use the same service ID for discovery as Nearby Share. I’m not sure what service ID Nearby Share uses, but if you search the ChromeOS codebase you should be able to find it. Additionally, the Android device will need to be in the “everyone” discoverability mode. I should mention that even if you discover Android devices with Nearby Connections, it will be difficult to send data. Since Nearby Share uses a custom packet format, you won’t simply be able to send files. I recommend making your own app that uses Nearby Connections on Android if you need to be able to also send data. As a side note, would you be interested in contributing your work to get Windows building? I think it would help a lot of other people 😊 |
Beta Was this translation helpful? Give feedback.
-
Thank you @bourdakos1 for your response. I would love to contribute my work to get this building on Windows. It was a long trail of errors to fix. And I agree it would help many others. |
Beta Was this translation helpful? Give feedback.
-
Looks like the Nearby Share source is also being added to this repo. You can find the service ID here: |
Beta Was this translation helpful? Give feedback.
-
Thanks for pointing to this. I0131 16:54:12.954299 38132 client_proxy.cc:330] ClientProxy [Endpoint Found]: [enter] id=E6AS; service=NearbySharing; info=325cc78f0e172a8d2faaf1373ddcb03a70; medium=BLE But for my phone, follwing is the data discovered - (code location) It also discovered another device with follwoing info - Is that the issue in Windows implementation or the advertising part? |
Beta Was this translation helpful? Give feedback.
-
It sounds like it was able to discover a Nearby Share device, but the "OnePlus Nord" bluetooth advertisement in your screenshot doesn't look to be an advertisement from Nearby Share |
Beta Was this translation helpful? Give feedback.
-
Is there a Android version requirement on Phone for Nearby share? Mine is Android 12. |
Beta Was this translation helpful? Give feedback.
-
I tried capturing the bluetooth traffic incoming from the phone using Wireshark on PC . It does not show NearbyShare advertisement. All the packets were like below - Bluetooth HCI Event - Extended Inquiry Result |
Beta Was this translation helpful? Give feedback.
-
You can search for "Nearby Share" in the setting of your phone. Make sure Nearby Share is turned on and has its visibility set to "everyone" |
Beta Was this translation helpful? Give feedback.
-
ok, so phone is discovered and connection accepted by phone from my console app when Google Nearby share is running on my windows pc where console app is running. Phone sends a disconnect message when connection is established. And payload transfer does not happen. I am attaching the log below - |
Beta Was this translation helpful? Give feedback.
-
Oh yes, I forgot to mention, your phone will need to be "nudged" into a discoverable mode. This can either be done by starting discovery on another device (in this case it was your Windows PC) or by using the "Files by Google" app and clicking "Receive" in the "Nearby Share" section of the app. Nearby Share will disconnect if you send payloads that don't follow Nearby Share's custom packet format. |
Beta Was this translation helpful? Give feedback.
-
thanks. Just to confirm since this will mostly need building ./sharing folder for windows as well which is bit of work. nearby/sharing/proto/wire_format.proto Line 134 in 6ad4bf7 Going through the code, I see that it sends an introduction frame first and then the payload. I will need to match what it looks for in the receiving part of code. do you have any documentation on the ./sharing code? |
Beta Was this translation helpful? Give feedback.
-
Hi, I am trying to figure out the custom packet format and it is requiring me to add a lot of dependent code from ./sharing folder to my project. Right now, I am stuck at resolving the dependency of PublicCertificateDatabase.
|
Beta Was this translation helpful? Give feedback.
-
Yes, you can skip the certificate stuff. That's just used for contacts/self share. |
Beta Was this translation helpful? Give feedback.
-
Looking at the code, looks like it needs certificate stuff - nearby/sharing/nearby_sharing_service_impl.cc Line 3213 in f8c907a nearby/sharing/nearby_sharing_service_impl.cc Line 3431 in f8c907a How do I skip it? If I own both apps, I can skip the flow but I need to communicate with Google's Nearby share on Android device. |
Beta Was this translation helpful? Give feedback.
-
This part of code also does not make sense - There is no action on receiving end when cert info is received - nearby/sharing/nearby_sharing_service_impl.cc Line 4048 in f8c907a How can I send my public cert to my mobile device and have Nearby Share use it? It says that it is to be shared offline. How is that shared offline? nearby/sharing/proto/wire_format.proto Line 295 in f8c907a |
Beta Was this translation helpful? Give feedback.
-
The certificate part isn't open source. You won't be able to build ./sharing without it, but if you manually write/parse frames, it can be skipped. If you don't use certificates, your app will just function as "everyone" mode in Nearby Share. Other devices will always be able to discover your app, but you will only be able to discover NS devices if they set their visibility to "everyone". |
Beta Was this translation helpful? Give feedback.
-
Thank you @bourdakos1 ! I am able to successfully transfer the file to phone from my app. Really appreciate your help in resolving the issues along the way! |
Beta Was this translation helpful? Give feedback.
-
Yay!! You can use a fast initiation advertisement to nudge the other device: |
Beta Was this translation helpful? Give feedback.
-
I see that fast initiation implementation is also missing in ./sharing folder. E.g. FastInitiationManager implementation is not available. which has dependency on adapter which looks like this - https://source.chromium.org/chromium/chromium/src/+/main:device/bluetooth/bluetooth_adapter_winrt.h Do you think this is what would be needed for fast initiation on Windows? Also, to confirm, it is the fast initiation advertisement from the sender which nudges the other device; is that correct? Can you share any details how that works? |
Beta Was this translation helpful? Give feedback.
-
Windows only needs the fast init advertiser to function, and correct, the advertisement is from the sender which nudges the other device. |
Beta Was this translation helpful? Give feedback.
-
I came across this documentation of this library. https://github.com/grishka/NearDrop/blob/master/PROTOCOL.md |
Beta Was this translation helpful? Give feedback.
-
Looks semi correct. However, I don’t recall the exact advertisement format off the top of my head. |
Beta Was this translation helpful? Give feedback.
-
Hello @bourdakos1, hope you are doing well! @rajendrasp and I have worked on setting up Google Nearby on Windows. While he is occupied elsewhere, I will be working on the fast initiation advertiser. Can you please tell help me with exact advertisement format? My plan is to broadcast it using a quick piece of code before investing in integrating Fast Initiation into our current fork of Google Nearby. Thank you! |
Beta Was this translation helpful? Give feedback.
-
Hello @bourdakos1, hope you are doing well! |
Beta Was this translation helpful? Give feedback.
-
I think you should be able to hardcode the advertisement to these values:
|
Beta Was this translation helpful? Give feedback.
-
Project
Nearby Connections
Language
C++
OS Platform
Windows
What happened?
I have setup the Nearby Connections library on Windows. It is building fine and I am able to StartDiscovery. However in the logs, it gives me following message when it finds my phone -
I0129 00:54:09.772869 46244 p2p_cluster_pcp_handler.cc:224] OnePlus Nord doesn't have any endpoint id, discarding.
I0129 00:54:09.772869 46244 p2p_cluster_pcp_handler.cc:274] Found unrecognized BluetoothDeviceName OnePlus Nord
I am trying with Nearby share from Android and why does it not have an endpoint id?
Would I be able to integrate the sample app created on Windows with Nearby share from Android?
What did you expect to happen?
My phone to get discovered on my Windows app which is using Nearby Connections library.
How can we reproduce it (as minimally and precisely as possible)?
I am trying with integrating the Connections library in a Windows app.
How often does this bug happen?
Every time
Standalone code to reproduce the issue
No response
Relevant log output
No response
Anything else we need to know?
No response
Beta Was this translation helpful? Give feedback.
All reactions