https://github.com/francescogabbrielli/beacons
Android Prototype: Beacons/Bluetooth LE Sensors Tracker
https://github.com/francescogabbrielli/beacons
android beacon bluetooth-low-energy eddystone temperature-monitoring
Last synced: about 1 month ago
JSON representation
Android Prototype: Beacons/Bluetooth LE Sensors Tracker
- Host: GitHub
- URL: https://github.com/francescogabbrielli/beacons
- Owner: francescogabbrielli
- License: gpl-3.0
- Created: 2017-01-02T13:11:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-05-01T15:10:54.000Z (about 9 years ago)
- Last Synced: 2025-10-18T17:13:18.809Z (8 months ago)
- Topics: android, beacon, bluetooth-low-energy, eddystone, temperature-monitoring
- Language: Java
- Homepage:
- Size: 2.87 MB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Beacons Transponder
## 0. Definitions
- **App**: the app running on a smartphone
- **DataManager**: a component of the app that will record the data for each device
and take care of transmitting them to the central repository (server)
when the network is available;
is also responsible for activating alerts and send real time notifications
to the user
- **Device**: a bluetooth low energy (BLE) device with sensors and data logger
- **Server**: database and backend engine
- **TransferService**: is a component running in a thread both in the DataManager and
the GATT connection managing client/server data interchange when a connection is
established:
CLIENT SERVER
---*---------------------------------------*--
| |
|[Send last data]>>-------------------->|
| |
| | 1. Data received (trigger actions)
| | 2. Store
| |
|<----------------------<<[Send confirm]|
| |
| 1. Remove Data* |
| 2. Update pointer to last data |
| |
* the data removed is not necessarily the last one, to allow a recent data
buffer on the client
If a connection is not available, data is stored in the client buffer queue
(or whatever acts as one).
In case of multiple data available to send, grouping and compression techniques
might be used.
In this proejct there are two transfer services that work in a chain, linked through
the smartphone: the first client is the device and the server is the smartphone
app (GATT connection background server); the second client is the smartphone app
(DataManager) and the server is the remote repository
## 1. When the app is installed
A background service will start whenever the bluetooth is turned on
The purpose of the service is to discover bluetooth devices and, if they are managed by the current
user/shipment, to connect to them establishing bidirectional GATT interaction
Device Smartphone Server
---*-------------------------------*--------------------------------*--
|<----------<<[Discover devices]| |
| | |
|[Discovered]>>---------------->| |
| | Updated info? |
| | |_NO_>[Query managed]>>------->|
| | | Query DB
| |<---------------<<[Managed info]|
| | Is Managed? |
|<-------------------<<[Connect]|<|_YES_ |
| | |_NO__>[no action] |
|[Connected]>>----------------->| |
| | SEE §2 |
|[Disconnected]>>-------------->| |
| | SEE §3 |
## 2. When a device connection is established
1. **a new GATT callback is created**
The GATT callback will register for notifications and manage interaction displaying the updated
data/reading from the device sensors. The data is sent to the DataManager with extra information
gathered from the smartphone (like position from GPS, time, etc...)
2. **a background service is started to extract data from the data logger**
It will begin from the pointer to the last data extracted and send it to the DataManager
(without additioanl info) and update the pointer to last data. It will also attempt to remove
extracted data from the device. This service is very similar to the service present in the DataManager
(*see __§0__*)
APP UI EXECUTOR GATT SERVICE CALLBACK THREAD
====*==============================*=================================*========================*===========
| . . .
| disconnected . . .
*>>--------[Connect]------------------------------------------->>+ .
. . | .
. . +>>---[OnConnection]--->>+
. . . | connected
*<<-------------------------------------[FireConnected]---------------------------------<<+
. . . |
. . *<<----[Discover]------<<+
. . | .
. . *>>----[OnDiscover]---->>*
. . . | services ok
. . *<<---(Check PW)-------<<*
. . | .
.....................................................................|......................................
. . | .
. . . | .
*>>-------[Check password]------------------------------------->>* .
. . | .
. . *>>----[OnWriteCh]----->>*
. . . | password set
. *<<-------------------------------------(ReadCfg)--------<<+
. | . | wrong pw
*<<----------------------------+--------[FireError]-------------------------------------<<*
. | . .
...................................|........................................................................
. | . .
. | . .
*>>----[ReadCfg]------------->>* . .
. | . .
. +>*>>-------[ReadCh]-------------->>* .
.<<-------[Progress]-------<<| . | .
. |-next | .
*>---------[Cancel]--------->| . *>>----[OnReadCh]------>>*
.<----[ProcessCanceled]-----<| . . |
. +<*<<-----------------------[Notify]-----------------------<<*
. | . .
*<<-----[ProcessComplete]----<<* . .
. . . .
............................................................................................................
. . . .
*>>----[Weak disconnect]----->>* . .
. | . .
*>---------[Cancel]----------->| . .
.<------[ProcessCanceled]-----<| . .
. | . .
*<<---[Condition not met]----<<*>>--------[Disconnect]--------->>* .
. . | .
*>>-------[Disconnect]----------------------------------------->>* .
. . | .
. . *>>--[OnDisconnection]->>*
. . . | disconnected
*<<-----------------------------------[FireDisconnected]--------------------------------<<*
. . . .
............................................................................................................
## 3. When the device disconnects
- Both the DataManager and the GATT data logger service are stopped istantaneously
- Connection/Disconnection status is treated like other data and sent to the server