1

I'm trying to send data between two devices in bluetooth working area.

Since bluetooth can't send files, I want to check whether the device is in bluetooth active area, and if so, send it a file through wi-fi. I tried to use GameKit, but it doesn't suit my needs, cause:

  1. I want to hide the transmit interface from user
  2. If it's possible, GameKit starts to use wi-fi immediately, which I don't need

As I see, the best way here is Bonjour with NSNetService class. But I still can't understand how to find out whether device is in bluetooth active area or not.

Since the main idea is to find out devices which are close to user's device, I also don't mind any other ideas how to measure the distance between devices except bluetooth service.

It's possible there're a lot of users in one place, so the less time it takes, the better.

Any help?

Thanks!

Riddick
  • 375
  • 4
  • 14

1 Answers1

0

Have a look at HHServices, which nicely hides the implementation details for service publishing / discovering via Bluetooth.

You basically want to use HHServices for publishing a "File Receive Service" on the receiving peers' side. On the sending side, you'll try to discover peers publishing this service. When discovering a peer offering your "File Receive Service", you know that peer is in Bluetooth range.

However, to send the file via WiFi, you'll need to get the target's WiFi address (or any other identification of the receiver) to the sender - possibly by publishing it in the FileReceiveService's TXT record.

domsom
  • 3,163
  • 1
  • 22
  • 27