Can BLE peripheral mode trigger the disconnection or refuse to connect? - android

Here's our situation. We have a machine vending machine run in peripheral mode and mobile runs in central mode. When the mobile is close to the vending machine, it triggers the connection and start to communicate. But as far as I know, the peripheral mode can only connect to one device at a time just considering bluetooh 4.0, so if there's someone who wants to make a trick stands around our vending machine and connects to it all the time, no one else can connect the vending machine. Am I right?
My question is
How to avoid this situation. Is it possible for the vending machine to refuse the connection or to trigger the disconnection when it founds that the connection is invalid (triggered by other app)?
I have heard something like multipoint bluetooth. So how much can the multi be, can it be like 100 so that it may solve the problem.
I found a similar situation in paypal beacon. https://devblog.paypal.com/how-does-paypal-beacon-work/ it says the beacon is running in peripheral mode. I am wondering how do they avoid these invalid connections.

Since, the central device(mobile device) initiating connection, it will act as Master and the other end device(vending machine) will act as slave.
According to Bluetooth 4.1 specification, a slave can have multiple masters.
So, more than one mobile device can connect to the single LE device.

Related

Securely connect Bluetooth device to Android

I am developing a device that needs to communicate securely to an Android app via Bluetooth. I need that only a predefined phone to be able to communicate with my device for security reason. And I also need to assure that this is not an intruder device that is trying to communicate falsified data to the app.
Looking at Bluetooth specs, I had the impression the only way to do that is with out of band (OOB) authentication with a pre-provisioning temporary key (TK). This looked very promising but after trying to find how to use OOB on an Android app, it seems like it is not supported.
Is it still possible to use OOB authentification on Android ?
If no, is there another alternative to solve my issue ?
This is doable but it depends on the BLE peripheral that you are developing and the features that it supports. Namely, your device needs to support Whitelisting and bonding. This is how it should work.
Upon first connection to the BLE device, the BLE device should accept the connection regardless.
Once the connection is made, the central device (Android phone) needs to initiate bonding. This doesn't need to be Out of Band (OOB) bonding, and the standard Just Works bonding should do.
Once bonding is succesful, the BLE peripheral should add the Android device's IRK to the list of whitelisted devices.
From this point onwards, the BLE peripheral will activate the whitelist, and therefore only devices in the whitelist will be able to connect to your BLE peripheral, and in your case it will be the Android phone that you used to make the very first connection.
It is not straight-forward and requires an initial secure-less connection with the target phone, but if that is not an issue then this should work.
You can find more information about this in the links below:-
Set and activate whitelist with Android phone
Android BLE server - allow only previously connected device to connect
Whitelisting with resolvable random addresses

Android Bluetooth Low Energy peripheral - Connection loss after bonding

I am implementing Bluetooth Low Energy's HID over GATT (HOGP) profile on Android Lollipop. My target is to use the phone as a keyboard/mouse, which can just plug and play with the default BLE (HID) drivers in Windows 8.1 laptop. The Android phone is supposed to act as BLE peripheral and the laptop should be in BLE central role.
Currently, I am able to establish a very short connection with the laptop. But just right after I enter the passkeys, and bonded successfully with the laptop, the BLE connection will be lost. Have anyone faced this kind of problems before? Or have any solutions on it?
Also, I failed to add generic access service to the gatt server in Android. I am curious if GAP service is included in Android BLE communication by nature? The reason I want to include this service is for defining the "device name", "appearance", and the "peripheral connection parameter update" characteristics. How I can do so?
Did you get your system fixed, I am seeing something kind of similar, where after bonding, my device will go to paired list, then about 20 sec later, the bluetooth on /off button will automatically switch to off position, wait 10 sec, then back
to on position, and my device is gone..

mutltiple active Bluetooth connection connectivity android

Is it possible to connect a android mobile bluetooth with multiple bluetooth devices. And I need all the connection active at the same time and can transfer data at same time too.
Yes. You can connect the phone with up to 7 devices (in theory). They form a 'piconet' with the phone as the master.
If the phone initiates the connection to the first two devices then it will likely be the master (as necessary).
If you find that you are having problems connecting more then one or two devices then you should root your phone, and run 'hcitool' to determine which are slave and which is master.
Come to think of it, Nexus devices just got a new Bluetooth stack in 4.2 and I don't know if it supports hcitool. If not, hopefully they have created an alternative.

Android Bluetooth: Service Discovery Failed, connection to Desktop/Laptop

I have an Android app that I had working a few months ago which I could use to connect my Droid X2 to an ASUS Transformer tablet over Bluetooth. That connection worked fine.
I just finished coding client/server pairs using PyBlueZ on a couple Ubuntu machines, and an analogous client/server pair using BlueCove on a Windows machine.
I thought it would be a breeze to take these three working, tested systems and connect them. Unfortunately, I am currently unable to connect my Droid X2 to my other machines, nor can I connect my other machines to my Droid X2 (I no longer have the ASUS Transformer). I can, however, connect my PyBlueZ client/server pair to my BlueCove client/server pair without issue.
Are there any known intricacies when connecting Android devices to desktops/laptops? Any additional information that must be provided, or differing formats in communication? I'm trying to connect using an insecure rfcomm channel to a service listing. I am using the same UUID on both sides. And, again, I had this exact insecure rfcomm service connection working between my Droid X2 and an ASUS Transfomer.
One interesting aspect is that even though all systems use the UUID, my PyBlueZ and BlueCove implementations also have a service name, but Android does not ask for a service name to connect to a service, only the UUID. Could that be an issue?
Thanks.
The error I was getting was Connection Refused when trying to connect over a bluetooth socket to my other devices. After much pain and research, I found that I could manually unpair my computers from my phone and then the bluetooth socket connects fine.
The strange thing is that I never even paired those devices, so I don't know how they got that way. But if you are getting Connection Refused, see if your Android device is paired to the machine you're connecting to, then manually unpair it, then try connecting with a bluetooth socket again.
Hope this saves someone a few hundred hours...

Android - modes of connectivity, device identification and device inter-communication?

Can someone explain a couple of very simple concepts to me - I'm interested in mobile devices running android and how they are identified over networks. Some scenarios:
Device is connected over WiFi - presumably the device has a standard IP address as with any host and can communicate with any other android host over TCP/IP (assuming it knows the participating device's IP?
Device is connected over bluetooth - how are devices identified in this case?
Device is connected over mobile operator's network - this is the one I'm interested in and confused by - is there anyway for two or more devices to discover each other and communicate via the mobile operator's network? How does a device communicate with a backend server in this scenario? In other words, how do apps and devices communicate when not connected to a WiFi network?
Thanks for any advice..
I'm only sure about the bluetooth thing, so i only answer this part:
The Bluetooth interface on your device has an MAC adresse. So while communicationg over Bluetooth you can assume that this MAC adresse is a unique identifier for a specific device. You can also reach other devices by establishing a connection over this MAC adress- However, to get this mac adress in the first place, you have to know it from somwhere, or you have to search for other bluetooth devices in the reachabla area before.
WiFi and 3g both attach the [mobile] device to the internet so it can make internet connections. 3G assigns a publicly addressable IP to the device, so one could, presumably open a server socket and listen for connections. The client would have to know the mobile IP, which may change quite frequently.
Bluetooth is more geared toward close-proximity. Devices in the vicinity can be connected to, after you have paired with them, which requires the cooperation of both devices which are to communicate.
If the goal is to produce an application which connects to nearby devices, I can think of the following ideas:
3g: all devices running the client register their position with a central database server. If the server detects that two clients are in close proximity, let them know so they can connect through the internet or through the server
WiFi: you could use the same idea as 3g, or use broadcast/multicast packets to broadcast your presence. Other apps can listen for those broadcasts and discover which other devices are near.
Bluetooth: A little trickier, as a device must be placed into discoverable mode in order for others to "see it". Discoverable mode is a temporary state and only lasts about 30 seconds (at a time).

Categories

Resources