Skip to content

Commit

Permalink
1.5.0
Browse files Browse the repository at this point in the history
- add navigation support
- add contacts support
  • Loading branch information
fbiego committed Oct 5, 2024
1 parent 6cb5e3e commit a75dc9d
Show file tree
Hide file tree
Showing 9 changed files with 842 additions and 297 deletions.
52 changes: 36 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Setup your ESP32 as a smartwatch and connect to Chronos app over BLE.

## Features

- [x] Time
- [x] Notifications
- [x] Weather
- [x] Time (Auto sync via BLE)
- [x] Notifications (Receive notifications from connected phone)
- [x] Weather (Receive weather info)
- [x] Controls (Music, Find Phone, Camera)
- [x] Phone Battery (Level, Charging state) (Chronos app v3.5.1+)
- [x] Navigation (Chronos app v3.7.5+)
- [x] Contacts & QR codes
- [ ] Alarms

## Companion App
Expand All @@ -24,11 +26,15 @@ Setup your ESP32 as a smartwatch and connect to Chronos app over BLE.
## Functions

```
// library
ChronosESP32();
ChronosESP32(String name); // set the BLE name
ChronosESP32(String name, ChronosScreen screen); // set the BLE name and screen configuration
void begin(); // initializes BLE
void loop(); // handles routine functions
ChronosESP32(String name, ChronosScreen screen = CS_240x240_128_CTF); // set the BLE name
void begin(); // initializes BLE server
void stop(bool clearAll = true); // stop the BLE server
void loop(); // handles routine functions
bool isRunning(); // check whether BLE server is inited and running
void setName(String name); // set the BLE name (call before begin)
void setScreen(ChronosScreen screen); // set the screen config (call before begin)
// watch
bool isConnected();
Expand All @@ -40,28 +46,33 @@ bool isCameraReady();
// notifications
int getNotificationCount();
Notification getNotificationAt(int index); // index [0-9]
Notification getNotificationAt(int index);
void clearNotifications();
// weather
int getWeatherCount();
String getWeatherCity();
String getWeatherTime();
Weather getWeatherAt(int index); // index[0-6]
HourlyForecast getForecastHour(int hour); // hour [0-23]
Weather getWeatherAt(int index);
HourlyForecast getForecastHour(int hour);
// extras
RemoteTouch getTouch();
String getQrAt(int index);
void setQr(int index, String qr);
// alarms
Alarm getAlarm(int index);
void setAlarm(int index, Alarm alarm);
// control
void sendCommand(uint8_t *command, size_t length);
void musicControl(uint16_t command);
void musicControl(Control command);
void setVolume(uint8_t level);
bool capturePhoto();
void findPhone(bool state);
// phone battery
// phone battery status
void setNotifyBattery(bool state);
bool isPhoneCharging();
uint8_t getPhoneBattery();
Expand All @@ -70,17 +81,26 @@ uint8_t getPhoneBattery();
int getAppCode();
String getAppVersion();
RemoteTouch getTouch(); // RemoteTouch(bool state, uint32_t x, uint32_t y)
String getQrAt(int index); // index [0-8]
// navigation
Navigation getNavigation();
// contacts
void setContact(int index, Contact contact);
Contact getContact(int index);
int getContactCount();
Contact getSoSContact();
void setSOSContactIndex(int index);
int getSOSContactIndex();
// helper functions for ESP32Time
int getHourC(); // return hour based on hour 24 variable
String getHourZ(); // return zero padded hour string based on hour 24 variable
int getHourC(); // return hour based on 24-hour variable (0-12 or 0-23)
String getHourZ(); // return zero padded hour string based on 24-hour variable (00-12 or 00-23)
String getAmPmC(bool caps = true); // return (no caps)am/pm or (caps)AM/PM for 12 hour mode or none for 24 hour mode
// callbacks
void setConnectionCallback(void (*callback)(bool));
void setNotificationCallback(void (*callback)(Notification));
void setRingerCallback(void (*callback)(String, bool));
void setConfigurationCallback(void (*callback)(Config, uint32_t, uint32_t));
void setDataCallback(void (*callback)(uint8_t *, int));
void setRawDataCallback(void (*callback)(uint8_t *, int));
Expand Down
118 changes: 118 additions & 0 deletions examples/navigation/navigation.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
MIT License
Copyright (c) 2024 Felix Biego
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.
______________ _____
___ __/___ /_ ___(_)_____ _______ _______
__ /_ __ __ \__ / _ _ \__ __ `/_ __ \
_ __/ _ /_/ /_ / / __/_ /_/ / / /_/ /
/_/ /_.___/ /_/ \___/ _\__, / \____/
/____/
*/

#include <ChronosESP32.h>

ChronosESP32 watch("Chronos Nav"); // set the bluetooth name

bool change = false;

void connectionCallback(bool state)
{
Serial.print("Connection state: ");
Serial.println(state ? "Connected" : "Disconnected");
}

void notificationCallback(Notification notification)
{
Serial.print("Notification received at ");
Serial.println(notification.time);
Serial.print("From: ");
Serial.print(notification.app);
Serial.print("\tIcon: ");
Serial.println(notification.icon);
Serial.println(notification.message);
}

void configCallback(Config config, uint32_t a, uint32_t b)
{
switch (config)
{
case CF_NAV_DATA:
Serial.print("Navigation state: ");
Serial.println(a ? "Active" : "Inactive");
change = true;
if (a){
Navigation nav = watch.getNavigation();
Serial.println(nav.directions);
Serial.println(nav.eta);
Serial.println(nav.duration);
Serial.println(nav.distance);
Serial.println(nav.title);
}
break;
case CF_NAV_ICON:
Serial.print("Navigation Icon data, position: ");
Serial.println(a);
Serial.print("Icon CRC: ");
Serial.printf("0x%04X\n", b);
break;
}
}

void setup()
{
Serial.begin(115200);

// set the callbacks before calling begin funtion
watch.setConnectionCallback(connectionCallback);
watch.setNotificationCallback(notificationCallback);
watch.setConfigurationCallback(configCallback);

watch.begin(); // initializes the BLE
// make sure the ESP32 is not paired with your phone in the bluetooth settings
// go to Chronos app > Watches tab > Watches button > Pair New Devices > Search > Select your board
// you only need to do it once. To disconnect, click on the rotating icon (Top Right)

Serial.println(watch.getAddress()); // mac address, call after begin()

watch.setBattery(80); // set the battery level, will be synced to the app
}

void loop()
{
watch.loop(); // handles internal routine functions

// if (change){
// change = false;

// Navigation nav = watch.getNavigation();
// if (nav.active){
// Serial.println(nav.directions);
// Serial.println(nav.eta);
// Serial.println(nav.duration);
// Serial.println(nav.distance);
// Serial.println(nav.title);
// }
// }

}
23 changes: 23 additions & 0 deletions examples/watch/watch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,29 @@ void configCallback(Config config, uint32_t a, uint32_t b)
}
Serial.println();
break;
case CF_CONTACT:
if (a == 0){
Serial.println("Receiving contacts");
Serial.print("SOS index: ");
Serial.print(uint8_t(b >> 8));
Serial.print("\tSize: ");
Serial.println(uint8_t(b));
}
if (a == 1){
Serial.println("Received all contacts");
int n = uint8_t(b); // contacts size -> watch.getContactCount();
int s = uint8_t(b >> 8); // sos contact index -> watch.getSOSContactIndex();
for (int i = 0; i < n; i++)
{
Contact cn = watch.getContact(i);
Serial.print("Name: ");
Serial.print(cn.name);
Serial.print(s == i ? " [SOS]" : "");
Serial.print("\tNumber: ");
Serial.println(cn.number);
}
}
break;
}
}

Expand Down
6 changes: 6 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ getPhoneBattery KEYWORD2
getForecastHour KEYWORD2
getTouch KEYWORD2
getQrAt KEYWORD2
getNavigation KEYWORD2

Notification LITERAL1
Alarm LITERAL1
Expand All @@ -43,6 +44,9 @@ ChronosData LITERAL1
ChronosScreen LITERAL1
RemoteTouch LITERAL1
HourlyForecast LITERAL1
Navigation LITERAL1
Control LITERAL1
Contact LITERAL1

MUSIC_PLAY LITERAL1
MUSIC_PAUSE LITERAL1
Expand Down Expand Up @@ -73,6 +77,8 @@ CF_CAMERA LITERAL1
CF_PBAT LITERAL1
CF_APP LITERAL1
CF_QR LITERAL1
CF_NAV_DATA LITERAL1
CF_NAV_ICON LITERAL1

CS_0x0_000_CFF LITERAL1
CS_240x240_130_STF LITERAL1
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ChronosESP32",
"version": "1.4.0",
"version": "1.5.0",
"keywords": "Arduino, ESP32, Time, BLE, Watch",
"description": "A library for ESP32 to interface with Chronos app over BLE",
"repository":
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ChronosESP32
version=1.4.0
version=1.5.0
author=fbiego
maintainer=fbiego
sentence=Setup your ESP32 as a smartwatch and connect to Chronos app over BLE.
Expand Down
4 changes: 3 additions & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
; https://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = esp32dev
; default_envs = esp32dev
default_envs = devkit

; Uncomment only one to test
src_dir = examples/watch
; src_dir = examples/camera
; src_dir = examples/control
; src_dir = examples/navigation


[env]
Expand Down
Loading

0 comments on commit a75dc9d

Please sign in to comment.