Skip to content

Commit a75dc9d

Browse files
committed
1.5.0
- add navigation support - add contacts support
1 parent 6cb5e3e commit a75dc9d

File tree

9 files changed

+842
-297
lines changed

9 files changed

+842
-297
lines changed

README.md

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ Setup your ESP32 as a smartwatch and connect to Chronos app over BLE.
88

99
## Features
1010

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

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

2628
```
29+
// library
2730
ChronosESP32();
28-
ChronosESP32(String name); // set the BLE name
29-
ChronosESP32(String name, ChronosScreen screen); // set the BLE name and screen configuration
30-
void begin(); // initializes BLE
31-
void loop(); // handles routine functions
31+
ChronosESP32(String name, ChronosScreen screen = CS_240x240_128_CTF); // set the BLE name
32+
void begin(); // initializes BLE server
33+
void stop(bool clearAll = true); // stop the BLE server
34+
void loop(); // handles routine functions
35+
bool isRunning(); // check whether BLE server is inited and running
36+
void setName(String name); // set the BLE name (call before begin)
37+
void setScreen(ChronosScreen screen); // set the screen config (call before begin)
3238
3339
// watch
3440
bool isConnected();
@@ -40,28 +46,33 @@ bool isCameraReady();
4046
4147
// notifications
4248
int getNotificationCount();
43-
Notification getNotificationAt(int index); // index [0-9]
49+
Notification getNotificationAt(int index);
4450
void clearNotifications();
4551
4652
// weather
4753
int getWeatherCount();
4854
String getWeatherCity();
4955
String getWeatherTime();
50-
Weather getWeatherAt(int index); // index[0-6]
51-
HourlyForecast getForecastHour(int hour); // hour [0-23]
56+
Weather getWeatherAt(int index);
57+
HourlyForecast getForecastHour(int hour);
58+
59+
// extras
60+
RemoteTouch getTouch();
61+
String getQrAt(int index);
62+
void setQr(int index, String qr);
5263
5364
// alarms
5465
Alarm getAlarm(int index);
5566
void setAlarm(int index, Alarm alarm);
5667
5768
// control
5869
void sendCommand(uint8_t *command, size_t length);
59-
void musicControl(uint16_t command);
70+
void musicControl(Control command);
6071
void setVolume(uint8_t level);
6172
bool capturePhoto();
6273
void findPhone(bool state);
6374
64-
// phone battery
75+
// phone battery status
6576
void setNotifyBattery(bool state);
6677
bool isPhoneCharging();
6778
uint8_t getPhoneBattery();
@@ -70,17 +81,26 @@ uint8_t getPhoneBattery();
7081
int getAppCode();
7182
String getAppVersion();
7283
73-
RemoteTouch getTouch(); // RemoteTouch(bool state, uint32_t x, uint32_t y)
74-
String getQrAt(int index); // index [0-8]
84+
// navigation
85+
Navigation getNavigation();
86+
87+
// contacts
88+
void setContact(int index, Contact contact);
89+
Contact getContact(int index);
90+
int getContactCount();
91+
Contact getSoSContact();
92+
void setSOSContactIndex(int index);
93+
int getSOSContactIndex();
7594
7695
// helper functions for ESP32Time
77-
int getHourC(); // return hour based on hour 24 variable
78-
String getHourZ(); // return zero padded hour string based on hour 24 variable
96+
int getHourC(); // return hour based on 24-hour variable (0-12 or 0-23)
97+
String getHourZ(); // return zero padded hour string based on 24-hour variable (00-12 or 00-23)
7998
String getAmPmC(bool caps = true); // return (no caps)am/pm or (caps)AM/PM for 12 hour mode or none for 24 hour mode
8099
81100
// callbacks
82101
void setConnectionCallback(void (*callback)(bool));
83102
void setNotificationCallback(void (*callback)(Notification));
103+
void setRingerCallback(void (*callback)(String, bool));
84104
void setConfigurationCallback(void (*callback)(Config, uint32_t, uint32_t));
85105
void setDataCallback(void (*callback)(uint8_t *, int));
86106
void setRawDataCallback(void (*callback)(uint8_t *, int));

examples/navigation/navigation.ino

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/*
2+
MIT License
3+
4+
Copyright (c) 2024 Felix Biego
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy
7+
of this software and associated documentation files (the "Software"), to deal
8+
in the Software without restriction, including without limitation the rights
9+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
copies of the Software, and to permit persons to whom the Software is
11+
furnished to do so, subject to the following conditions:
12+
13+
The above copyright notice and this permission notice shall be included in all
14+
copies or substantial portions of the Software.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
SOFTWARE.
23+
24+
______________ _____
25+
___ __/___ /_ ___(_)_____ _______ _______
26+
__ /_ __ __ \__ / _ _ \__ __ `/_ __ \
27+
_ __/ _ /_/ /_ / / __/_ /_/ / / /_/ /
28+
/_/ /_.___/ /_/ \___/ _\__, / \____/
29+
/____/
30+
31+
*/
32+
33+
#include <ChronosESP32.h>
34+
35+
ChronosESP32 watch("Chronos Nav"); // set the bluetooth name
36+
37+
bool change = false;
38+
39+
void connectionCallback(bool state)
40+
{
41+
Serial.print("Connection state: ");
42+
Serial.println(state ? "Connected" : "Disconnected");
43+
}
44+
45+
void notificationCallback(Notification notification)
46+
{
47+
Serial.print("Notification received at ");
48+
Serial.println(notification.time);
49+
Serial.print("From: ");
50+
Serial.print(notification.app);
51+
Serial.print("\tIcon: ");
52+
Serial.println(notification.icon);
53+
Serial.println(notification.message);
54+
}
55+
56+
void configCallback(Config config, uint32_t a, uint32_t b)
57+
{
58+
switch (config)
59+
{
60+
case CF_NAV_DATA:
61+
Serial.print("Navigation state: ");
62+
Serial.println(a ? "Active" : "Inactive");
63+
change = true;
64+
if (a){
65+
Navigation nav = watch.getNavigation();
66+
Serial.println(nav.directions);
67+
Serial.println(nav.eta);
68+
Serial.println(nav.duration);
69+
Serial.println(nav.distance);
70+
Serial.println(nav.title);
71+
}
72+
break;
73+
case CF_NAV_ICON:
74+
Serial.print("Navigation Icon data, position: ");
75+
Serial.println(a);
76+
Serial.print("Icon CRC: ");
77+
Serial.printf("0x%04X\n", b);
78+
break;
79+
}
80+
}
81+
82+
void setup()
83+
{
84+
Serial.begin(115200);
85+
86+
// set the callbacks before calling begin funtion
87+
watch.setConnectionCallback(connectionCallback);
88+
watch.setNotificationCallback(notificationCallback);
89+
watch.setConfigurationCallback(configCallback);
90+
91+
watch.begin(); // initializes the BLE
92+
// make sure the ESP32 is not paired with your phone in the bluetooth settings
93+
// go to Chronos app > Watches tab > Watches button > Pair New Devices > Search > Select your board
94+
// you only need to do it once. To disconnect, click on the rotating icon (Top Right)
95+
96+
Serial.println(watch.getAddress()); // mac address, call after begin()
97+
98+
watch.setBattery(80); // set the battery level, will be synced to the app
99+
}
100+
101+
void loop()
102+
{
103+
watch.loop(); // handles internal routine functions
104+
105+
// if (change){
106+
// change = false;
107+
108+
// Navigation nav = watch.getNavigation();
109+
// if (nav.active){
110+
// Serial.println(nav.directions);
111+
// Serial.println(nav.eta);
112+
// Serial.println(nav.duration);
113+
// Serial.println(nav.distance);
114+
// Serial.println(nav.title);
115+
// }
116+
// }
117+
118+
}

examples/watch/watch.ino

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,29 @@ void configCallback(Config config, uint32_t a, uint32_t b)
281281
}
282282
Serial.println();
283283
break;
284+
case CF_CONTACT:
285+
if (a == 0){
286+
Serial.println("Receiving contacts");
287+
Serial.print("SOS index: ");
288+
Serial.print(uint8_t(b >> 8));
289+
Serial.print("\tSize: ");
290+
Serial.println(uint8_t(b));
291+
}
292+
if (a == 1){
293+
Serial.println("Received all contacts");
294+
int n = uint8_t(b); // contacts size -> watch.getContactCount();
295+
int s = uint8_t(b >> 8); // sos contact index -> watch.getSOSContactIndex();
296+
for (int i = 0; i < n; i++)
297+
{
298+
Contact cn = watch.getContact(i);
299+
Serial.print("Name: ");
300+
Serial.print(cn.name);
301+
Serial.print(s == i ? " [SOS]" : "");
302+
Serial.print("\tNumber: ");
303+
Serial.println(cn.number);
304+
}
305+
}
306+
break;
284307
}
285308
}
286309

keywords.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ getPhoneBattery KEYWORD2
3434
getForecastHour KEYWORD2
3535
getTouch KEYWORD2
3636
getQrAt KEYWORD2
37+
getNavigation KEYWORD2
3738

3839
Notification LITERAL1
3940
Alarm LITERAL1
@@ -43,6 +44,9 @@ ChronosData LITERAL1
4344
ChronosScreen LITERAL1
4445
RemoteTouch LITERAL1
4546
HourlyForecast LITERAL1
47+
Navigation LITERAL1
48+
Control LITERAL1
49+
Contact LITERAL1
4650

4751
MUSIC_PLAY LITERAL1
4852
MUSIC_PAUSE LITERAL1
@@ -73,6 +77,8 @@ CF_CAMERA LITERAL1
7377
CF_PBAT LITERAL1
7478
CF_APP LITERAL1
7579
CF_QR LITERAL1
80+
CF_NAV_DATA LITERAL1
81+
CF_NAV_ICON LITERAL1
7682

7783
CS_0x0_000_CFF LITERAL1
7884
CS_240x240_130_STF LITERAL1

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ChronosESP32",
3-
"version": "1.4.0",
3+
"version": "1.5.0",
44
"keywords": "Arduino, ESP32, Time, BLE, Watch",
55
"description": "A library for ESP32 to interface with Chronos app over BLE",
66
"repository":

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=ChronosESP32
2-
version=1.4.0
2+
version=1.5.0
33
author=fbiego
44
maintainer=fbiego
55
sentence=Setup your ESP32 as a smartwatch and connect to Chronos app over BLE.

platformio.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
; https://docs.platformio.org/page/projectconf.html
1010

1111
[platformio]
12-
default_envs = esp32dev
12+
; default_envs = esp32dev
13+
default_envs = devkit
1314

1415
; Uncomment only one to test
1516
src_dir = examples/watch
1617
; src_dir = examples/camera
1718
; src_dir = examples/control
19+
; src_dir = examples/navigation
1820

1921

2022
[env]

0 commit comments

Comments
 (0)