Android App for connecting HabitatMap's AirBeam2 sensors to an Android smartphone and transmitting values in real-time via MQTT and OAuth2 authentication. See the App - Quickstart Guide
Currently the app is used in the research project DE4L (Data Economy 4 Advanced Logistics) funded by the German Federal Ministry for Economic Affairs and Energy (01MD19008A).
Developed by InfAI Management GmbH in Leipzig, Germany.
- Real-time data connection using MQTT
- OAuth2 Token authentication for MQTT and automatic token refresh
- MQTT message buffering using Room when connection to MQTT server is lost
- In case Bluetooth connection to sensor is lost, reconnect procedure is initiated
- Paho MQTT Client
- Okta OIDC Android for OpenID Connect Authentication
- Hilt for Dependency Injection
- Android Jetpack (e.g. Room and Livedata)
- Google Guava
- GreenRobot EventBus
- Kotlin Coroutines and Flows
Include the following properties in your local.properties
file and set the properties accordingly:
# Authentication
AUTH_DISCOVERY_URI="{DISCOVERY_URI}" #EXAMPLE https://auth.example.org/auth/realms/my-awesome-realm
AUTH_CLIENT_ID="{CLIENT_ID}"
AUTH_REDIRECT_URI="com.example.app:/start-app" #EXAMPLE VALUE
AUTH_REDIRECT_URI_END_SESSION="com.example.app:/session-ended" #EXAMPLE VALUE
AUTH_USERNAME_CLAIM_KEY="preferred_username" #USE TO GET USERNAME FROM KEYCLOAK TOKEN
AUTH_MQTT_CLAIM_RESOURCE="{RESOURCE_ID}" #USE TO ACCESS KEYCLOAK RESOURCE ROLES
AUTH_MQTT_CLAIM_ROLE="{RESOURCE_ROLE}" #REQUIRED RESOURCE ROLE
# MQTT
MQTT_SERVER_URL="{MQTT-BROKER-URL}" #EXAMPLE: ssl://broker.example.com:8883
MQTT_OAUTH_USERNAME="{MQTT_OAUTH_USERNAME}" #SEE NOTE BELOW
Note: Within the DE4L project VerneMQ is used as MQTT broker in combination with an authentication service which integrates into the VerneMQ authentication process by using webhooks. The authentication service provides an OAuth2 token authentication mode which is indicated by a fixed username, hence the MQTT_OAUTH_USERNAME parameter. The access token is then sent using the password parameter.
- support multiple sensors
- support more sensor types
- [AIRBEAM2] AirBeam2 sensor occasionally produces unparseable lines
- [PAHO] If MQTT client is connected to a mobile network and device is connected to WiFi, MQTT connection stays in mobile network
MIT License
Copyright (c) 2021 InfAI Management GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Google Play and the Google Play logo are trademarks of Google LLC.
- All trademarks are property of their respective owners.