Is it possible for an iOS/Android app to transmit data to a remote server when it picks up an iBeacon signal. The app will run in the background.
Lets assume the iBeacon is equipped with an internet connection as well. Will the beacon be able to pick up the data transmitted from the smartphone app?
What I'm trying to achieve is this:
An IoT device works as an iBeacon (and motion sensor)
The IoT device picks up motion via the sensor
The IoT contacts a remote server to find out if a given smartphone is within close range of it.
The IoT performs some sort of operation based upon if the smartphone is close or not.
Would this be possible?
Yes and No.
Yes, an iOS/Android app in the background can transmit data to a remote server when it detects an iBeacon signal. This is a very common use case, and I have built several apps that do this.
No, an iBeacon cannot send data to a server for two reasons:
An iBeacon is a transmit only device. It does nothing more than regularly send out an advertisement packet with a unique identifier. By design, it does not listen or receive. While you could certainly build some other custom Bluetooth LE device that does this, it would not be a standard iBeacon.
Typically iBeacon devices do not have internet connections.
What you describe is certainly possible if you build a general purpose computer with an internet connection that also sends out an iBeacon transmission as a small part of what it does. I have built such systems out of Raspberry Pi computers, and stationary Android/iOS devices. But you could also do this with a laptop, desktop, or smaller embedded device.
The key distinction in being able to do this is recognizing that you can't just buy an off-the-shelf iBeacon and make this work. You have to build your own IoT device based on a small computer with an internet connection that is augmented to transmit an iBeacon advertisement.
Related
I'm trying to implement a Bluetooth (BLE) gateway into a project to transfer data between hardware and a mobile device with an application. The hardware is not unique, it could be mass produced with the controller having the same program flashed into it.
If 100 of the hardware product is made, powered up sitting side by side, what is the best way to set up the information that the BLE broadcasts to advertise so that it can be received by a mobile device, and only 1 hardware and mobile device can be connected at any time.
For example, if you have 3 of the same fitness tracking watches side by side, and you only want to connect to 1 of them, how do you distinguish which is which on say the phones bluetooth pairing menu.
Does each of the manufactured hardware need to have a unique ID that shows on the mobile device (eg ABC11, ABC112, ABC113 etc), and how do you program 100 unique programs into the hardware quickly.
On the other hand, should each of the hardware have the same ID broadcast, and then the user just hopes for the best if the correct hardware is paired.
(BTW, the hardware is an arduino based microcontroller using a BM70 BLE module. neither of which are intended to be modified by the user)
Assistance appreciated.
Thanks. Nunya
You do not have to manually program a different MAC addresses for each device, the BM70 module is the one that provides the BLE MAC address and they are supposed to have unique ones. Sometimes manufacturer recycle (reuse) the addresses, but I think the chance to hit a MAC twice with 100 devies is pretty low.
If your devices are all the same and use the same program they all offer and advertise the same BLE service. The service and containing characteristics are the feature that distinguishes your devices from other BLE devices. A true BLE device that does not also use Bluetooth Classic will not show up in your phones bluetooth settings or pairing menu. BLE requires a dedicated app where you scan for BLE devices and idealy filter for the special service you are using to only find your own devices.
To distinguish between 100 devices placed next to each other (if this even matters since they are all the same) you need to either read the MAC address and prit it on a label for each device or use some status LEDs to show the connection status on your arduino. If you connect to one device the LEDs could start blinking to show which device you are connected to.
Currently, I am developing an app which is communicating with one BLE Hardware which is receiving commands and responding back the command response. To Simulate hardware, We have developed one iOS Simulator app, which is working in Peripheral and responding back on requested command. But Somehow, As and when I try to write to the write characteristics, I got the status = BluetoothGatt .GATT_REQUEST_NOT_SUPPORTED in the onCharacteristicWrite callback. But somehow, I came to know that we need to implement the Central and Peripheral roles into Android app.
But I am still not sure, Do we need to implement Peripheral role as well to send and receive data in multiple packets.
I am developing the app using following nice blog post:
- https://medium.com/#avigezerit/bluetooth-low-energy-on-android-22bc7310387a
- https://android.jlelse.eu/android-bluetooth-low-energy-communication-simplified-d4fc67d3d26e
- https://www.bignerdranch.com/blog/bluetooth-low-energy-on-android-part-2/
And using following repo as learning point of view:
- https://github.com/bignerdranch/android-bluetooth-testbed/tree/a/android-ble-part-3
Thanks in advance!
Typically your phone app is the central and it communicates with a peripheral device over Bluetooth. If you want to send data to the peripheral, you can write a characteristic in the phone app, given writing is enabled for that characteristic. Your central can get data from the peripheral in 2 ways: it can either read a characteristic (if it's enabled) from the peripheral or receive notifications from the peripheral (if it's enabled). So if all you have is a central (phone app) and a peripheral (some kind of Bluetooth device) and you want to send data back and forth, you don't need to have both central and peripheral roles in the phone app. If you have some special stuff going on, it might be different for you, I don't know. I'm talking about a typical setup.
If you want to send commands to the peripheral, you could write those commands to a characteristic. The peripheral could in turn respond with notifications. This is basically the way I develop a Bluetooth solution, but it can be different depending what you want to achieve.
It takes two devices to communicate with each other.
Device A:
It will be Peripheral device which will be advertising the data. i.e.: Beacons, BLE Hardware
Device B:
It will be Central device which will send request for read,write. i.e.: Mobile
Setup for Device A:
If you don't have Peripheral, there is a way to make your android mobile to act like a Peripheral if your device is supporting that advance feature.
So before beginning, you may simply check that by using following app:
https://play.google.com/store/apps/details?id=com.kyriakosalexandrou.bluetoothsupportcheck
To make your device act like Peripheral, you may install following app which simply simulates the GATT and advertising:
https://play.google.com/store/apps/details?id=com.ble.peripheral.sim
Important: Setup service and characteristics based on your requirements, make sure characteristic is write enabled if you want write data on it.
My Google Glass and Mobile supports Bluetooth LE.Can I use the Bluetooth LE for two way communication between Glass and mobile.I try to send an image from Glass to mobile and again send response to Glass using bluetooth LE.Is it possible to do this?
Yes it is possible. First, decide which device is Central; usually the smartphone should be, as it's got more resources and power. Then when the two connect, their GATT roles (Client and Server) are interchangeable at any time, because GATT roles are independent of GAP roles (Central and Peripheral). Simply issue a GATT request from any of the two applications.
Sidenote: BLE is not designed for sending images. Each radio packet contains maximum 23 bytes of application data, so imagine how many packets you need for an image.
I'm not a developer but I'm curious about the connectivity options between smartphones.
Looks like BLE is the only technology that is available on both Android and ios that could make an connection possible in the foreground, but is able to scan in the background?
If I walked around with my phone in the pocket, could it scan in intervalls for other devices`UUIDs/mac addresses and save the data realibly without the process being shut down after a while?
the app would have to work between Android phones, ios Devices,
and Android phones-ios Devices.
I dont want a stable connection. I'm only speaking about gathering UUIDs and mac adresses in the background. whichever is more suitable to uniquely identify a device.
Thanks in advance.
iOS devices with BLE support can act as the peripheral and/or the central role. The peripheral advertises its services, and the central discovers them (via scanning). You need Android 5.0+ to support peripheral mode.
Once a central discovers a peripheral, the central can obtain advertisement details from it, including a unique peripheral ID. This is similar to a MAC address, though some peripherals randomly generate these IDs.
In general, an iOS or Android device acts in the central role and it doesn't advertise anything. There is nothing to discover. However, you could write an app that acts as both a peripheral and a central.
On iOS, your app can perform both BLE roles in the background (your app doesn't need to be in the foreground).
You would want to do background tasks responsibly as both advertising and scanning require the radio, which uses a significant amount of power (drains the battery).
There are many issues with the current BLE stack on Android (e.g. using WIFI and BLE at the same time because they share the radio). The BLE API first became available for Android with 4.2.
The iPhone 4s and later has BLE with the API first available in iOS 6.
I have to make an application to pair an iOS and Android device (iPhone 5, iPad 3, Galaxy S3, Nexus 7 they all use Bluetooth 4.0) and then send data to each other.
Is this amount of data limited ? Can we send something like a photo or a PDF?
I've already done the pairing and sending data between 2 iOS devices using CoreBluetooth and the sample code from Apple BTLE_Transfer
Of what i understood, a Peripheral (Server) can Advertise to a Central (Client).
This central is scanning around itself, and then try to find the Server by looking for the UUID of the service advertised.
When i make a Server on Android, it is waiting for a connection (listening), i know the UUID and the mac address of my Server.
But when i scan with my iPhone (scanning for the same UUID of course), i can't find the server.
So is there a possibility for the android server to advertise like the Peripheral on iOS?
Or maybe a possibility for my iPhone client to connect using the mac address of the server?
Q: Is this amount of data limited ? Can we send something like a photo or a PDF?
Bluetooth Low Energy was not optimised for sending large amounts of data, nor is it optimised for streaming. It is more suitable for sending small chunks of data periodically (e.g. temperature readings, time, etc). Please have a look at this answer to understand how BLE transfer is different from classic Bluetooth. That being said, you can still send large amounts of data over BLE, and the amount of data is unlimited. However, this might end up being unreliable and relatively slow.
Q: So is there a possibility for the android server to advertise like the Peripheral on iOS?
Being a server/client is a completely different thing from being a peripheral/central:-
Peripheral/central dictates how the connection is made. A central device should initiate the connection. A peripheral device should advertise and wait for a connection request.
Client/Server dictates how the data is distributed. The Gatt Server holds the data. The Gatt Client can read, write or be notified (getting a continuous stream of readings) of this data. In most cases, the server is also the peripheral, but this is not mandatory.
So to answer your question, yes, the server can advertise like the peripheral on iOS. However, for Android, this feature is not yet available and will be part of the next version (Android L) release. Please see this answer for more information.
Q: Or maybe a possibility for my iPhone client to connect using the mac address of the server?
As far as I know, in coreBluetooth you would need the UUID, not the MAC Address, of a peripheral device to connect to it. You do not need to know the services being advertised from the peripheral device. Your best bet would be to scan for peripheral devices, and then connect to the one with the UUID and/or the advertising data that u know belong to your peripheral.
I hope this helps.
I'm not sure. Bluetooth LE isn't good idea to transfer large files. In one request phone you have only 18 bytes.
Nexus 7 bluetooth chip has some defect - not work correctly.
Try free application for IPhone - Light Blue.
so...
First question: yes.
Second: Yes but it's not good idea. MAc address in Iphone is alternating every 10 minutes and all turn on/off bluetooth.
In general, sending large files is best done using an internet connection (over the cloud), there are many frameworks that can cut down the overhead for you.
However, the main question is still how to discover to which device you would want to send the data.
There could be multiple ways of doing that on your own such as using BLE or even sound.
To be honest, its a lot of work so if your app is end-user driven, i would suggest using a framework that can do cross platform discovery for you such as: http://p2pkit.io or google nearby.
Disclaimer: i work for Uepaa developing p2pkit for iOS and Android