Wearlive is accessible at https://wearlive.davidestebanmunoz.com .
Wearlive is divided into two different parts, an android wear App and a web service. Both of them have been developed 100% by me.
Wearlive Android Wear app
Wearlive android wear app is a native android app, coded in Java using Android Studio as IDE.
It receives GPS location each 5 seconds from Android system, and sends it to wearlive.tk server by UDP. It is really useful if you have a smartwatch with e-sim.
Before starting using it, android watch serial number must be registered into https://wearlive.davidestebanmunoz.com .
For privacy and security purposes, tracks can be protected using password, in that case Protect switch must be set .
Once serial number has been registered, just switch on “Start tracking” and start with your activity, app will launch a background service that will send your location every 5 seconds. The app itself shows when it is live tracking and when Android has got a valid GPS status.
One special trick of this app is that it works even if the APN of the mobile network operator is not correctly set. This is because in Spain, Movistar disabled its HTTP proxy on April 2021 and Android Wear does not allow us to modify APN. So using raw UDP frames allows to bypass this problem. Also, as UDP is connectionless, battery usage has been reduced.
Using a Xiaomi Mi Watch this app has used 38% of its battery for 10km and 56 minutes session.
Wearlive Web Server
Wearlive web server is formed using several docker containers and technologies:
The blue stack is the same we saw on previous posts and its explanation can be seen here.
The green stack has a NGINX for web server, PHP docker for getting location data from MariaDB and also for registering users and the Python docker receives UDP frames at 20002 port and if its data is valid and the serial of the sender has been registered, inserts location into MariaDB.
The docker-compose recipe of green stack can be seen here:
version: '3' services: db_wearlivetk: image: mariadb:10.5 container_name: db_wearlivetk restart: unless-stopped env_file: .env environment: - MYSQL_DATABASE=$WEARLIVE_MYSQL_DATABASE - MYSQL_USER=$WEARLIVE_MYSQL_USER - MYSQL_PASSWORD=$WEARLIVE_MYSQL_PASSWORD - MYSQL_ROOT_PASSWORD=$WEARLIVE_MYSQL_ROOT_PASSWORD volumes: - "/home/ubuntu/dockers/wearlive/data/db/:/var/lib/mysql" #command: '--default-authentication-plugin=mysql_native_password' networks: - david webwearlive: container_name: webwearlive depends_on: - db_wearlivetk build: dockerfile: Dockerfile_php image: php7-fpm_mysqli volumes: - "/home/ubuntu/dockers/wearlive/data/html:/var/www/html" env_file: .env environment: - DB_HOST=db_wearlivetk:3306 - DB_USER=$WEARLIVE_MYSQL_USER - DB_PASSWORD=$WEARLIVE_MYSQL_PASSWORD - DB_NAME=$WEARLIVE_MYSQL_DATABASE networks: - david wearlive_receiver: depends_on: - db_wearlivetk build: dockerfile: Dockerfile_wearlive_receiver image: wearlive_receiver:0.0.1 container_name: wearlive_receiver restart: unless-stopped env_file: .env environment: - DB_HOST=db_wearlivetk - DB_USER=$WEARLIVE_MYSQL_USER - DB_PASSWORD=$WEARLIVE_MYSQL_PASSWORD - DB_NAME=$WEARLIVE_MYSQL_DATABASE volumes: - "/home/ubuntu/dockers/wearlive/data/receiver:/code/" networks: - david command: python /code/udp_server.py ports: - 20002:20002/udp wearlive_nginx: image: nginx depends_on: - webwearlive container_name: wearlive_nginx networks: - proxy_nginx-proxy - david environment: - VIRTUAL_HOST=wearlive.davidestebanmunoz.com - LETSENCRYPT_HOST=wearlive.davidestebanmunoz.com volumes: - "/home/ubuntu/dockers/wearlive/data/nginx/etc_nginx:/etc/nginx" - "/home/ubuntu/dockers/wearlive/data/html:/var/www/html" phpmyadmin: image: arm64v8/phpmyadmin container_name: phpmyadmin depends_on: - db_wearlivetk links: - db_wearlivetk:db networks: - david environment: PMA_HOST: db_wearlivetk PMA_PORT: 3306 PMA_ARBITRARY: 1 MYSQL_ROOT_PASSWORD: $WEARLIVE_MYSQL_ROOT_PASSWORD restart: always ports: - 8081:80 networks: david: proxy_nginx-proxy: external: true
As can be seen in recipe, in this case dockerfiles have been used , for PHP(webwearlive) and for Python(wearlive_receiver) dockers. In both cases, it is used to install MySQL support.
FROM php:7-fpm RUN docker-php-ext-install mysqli RUN docker-php-ext-enable mysqli
FROM python:3.8-slim RUN pip install pymysql
In case the user has selected to protect its live tracking with a password, it is prompted before allowing to see where is it.
- Type: Android APP + Website
- Where: Android app on smartwatches + Docker containers on VPS
- Github repo: no