Bluetooth Smart: is it sensible to choose a device based on its peripheral name - ios

I have an application (Basically an Arduino) that I connect to from iOS (and might use Android in the future as well) using BLE. I reprogram the BLE hosts to a specific value so that the when I ask the peripherals name after it gets discovered in iOS can be accepted or rejected.
I'm however not sure that this is a good way to do. The name has a code that users can easily change to an other (always valid) code. That way if two modules are up and running at the same time, users will be sure that only the module they are linked to is the one they want to be linked to. This is a bit the same like connecting a mouse / keyboard of course using 'normal' bluetooth.

Related

ESP32 iPhone Bluetooth, just a general question

I'm writing some code (C++) for ESP32, to act as a BLE beacon. The problem is this: the iPhone doesn't send out its real MAC address, but does a random-generated MAC address, for security. The thing I'm confused about is how do you know if it's a device you've previously paired with?
So let's say I detect a new BLE MAC address, and looking at the manufacturer data I can determine it's an Apple device (first 2 bytes are "4C").
Now I need to know if I've previously paired with that device, so that I can allow the ESP32 to initiate an action (for simplicity let's just say turn on an LED). If that MAC address is in a list of known devices, then I can continue, and if not, I ignore it.
The problem is, if the iPhone is not giving up the real MAC address, the detected MAC address will never match anything. As this is a security situation I'm sure the algorithm for generating those MAC addresses is not known.
To be clear: this code is being written for the ESP32, not the iPhone.
It is in fact not possible to tell if a device has been previously seen, unless you pair and establish a bond with it. Once you pair with the device, long-term keys are exchanged and are used to quickly re-establish the connection.
This is by design. MAC addresses were originally unique, but this allowed tracking people and devices without their consent. You can read more about this in the following ESP-IDF guides:
GATT security server walkthrough
GATT security client walkthrough
So are you using esp32 as a beacon? This dose not involve any pairing or iOS MAC addresses. iOS will just be able to listen and the esp32 will not even know someone is "listening" to its broadcast.
Probably iOS application can store which services it is interested to hear to; may looks like pairing.. but it is a high level application managed technique and not any related to what BT standard calls pairing.

Automatic connection between 2 IOS Apps

I have written a Solution that contains two Apps,
the first app acts like a remote control app and the second app display some stuff depending on the selection of the first app.
State Now:
Currently, both apps communicate over a Bluetooth connection using the MultipeerConnectivity.framework.
Problem:
I have always to pair both apps manually starting the apps.
Solution:
Starting both apps, they should detect each other and be paired automatically.
How could I solve my Problem, is there any alternative to the Bluetooth connection or can I set up the connection to have trusted devices or something like that?
It's up to you as the developer how the pairing is implemented. You could even code a solution which requires no approval from the user; the app could pair automatically with any device looking for other peers (although this probably wouldn't be a good idea for a variety of reasons).
One possible solution for your problem:
The first time your devices pair, you generate a random UUID and save it on both devices for later use.
The next time your devices discover one another, they check to see if they have any matching UUIDs stored; if they do find a matching pair then you can let them connect automatically.

Update BLE Device Name with the device_name Characteristic Best Practice

What is the best practice for using the Bluetooth Low Energy Generic Access Profile Service (0x1800)?
Is there a reason that iOS prevents developers from using the Generic Access Profile Services and Characteristics?
Section 3.12 (page 24) documents the fact iOS does not
let a developer use that Service (and a couple others)
https://developer.apple.com/hardwaredrivers/BluetoothDesignGuidelines.pdf
I've also seen some hardware implementations on microcontrollers that also seem to hide this Service from a developer in the firmware.
The work around that I (and most others) have done to allow an app to update the device_name to is to make a separate custom Service-Characteristic that updates the local device name and updates the name in the advertising packet. This is not ideal for many reasons and I am wondering if I am missing something. Should we all be able to use the 0x2A00 Characteristic just like any other Characteristic?

Programmatically connect or detect to a certain WiFi in iOS?

In advance I am sorry for my English.
The task consists in defining, whether there is a person in a certain place (at certain office, for example), and to activate depending on it certain possibilities of the appendix.
At first I thought of definition of information on WiFi (or check of the same SSID, or automatic connection to the hidden network with set in the SSID appendix and the password), but, seemingly, not to make it without jailbreak (if somebody knows how - please, answer).
I think, GPS - not the best exit as it is possible to be out of the room, using it.
By the way, I already saw apps determining by WiFi of a point of access so it can be made somehow. I guess.
Actually, question. How it is better to define in the application, whether there is a device within, for example, premises of office?
Basically, if you know location coordinates you can safely use CoreLocation framework. Whether your target device supports region monitoring it will be perfect. It uses not only GPS, but WiFi and GSM as well
Look here: https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/CLLocationManager/CLLocationManager.html
If you really need to get network name you can play with CNCopyCurrentNetworkInfo function of CaptiveNetwork framework.
See:
https://developer.apple.com/library/ios/documentation/SystemConfiguration/Reference/CaptiveNetworkRef/Reference/reference.html

Transfer data over wifi without a database

I want to get to know how I can transfer data easily between 2 iPhones, over wifi. I would like to know if I could do that without having a server or database, but within an app (so without using email).
Game Kit has support for Peer-to-Peer-Connectivity and is, despite the name, not only usable for games:
The GKSession class allows your application to create and manage an
ad-hoc Bluetooth or local wireless network, as shown in Figure 1.
Copies of your application running on multiple devices can discover
each other and exchange information, providing a simple and powerful
way to create multiplayer games on iOS. Further, sessions offer all
applications an exciting mechanism to allow users to collaborate with
each other.
You can also check out Bonjour API from Apple. I am not sure if you need a static IP for it to work or it can just work over wifi. Just trying to give a pointer.
Based on your exact usecase, it can work well.
Check it out here, Game center is also there.
http://developer.apple.com/technologies/ios/networking.html

Resources