Skip to content

Commit 41ab3d1

Browse files
committed
1.0.1
- rename library
1 parent 0369572 commit 41ab3d1

File tree

8 files changed

+61
-61
lines changed

8 files changed

+61
-61
lines changed

Chronos.cpp renamed to ChronosESP32.cpp

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*/
3232

3333
#include <Arduino.h>
34-
#include "Chronos.h"
34+
#include "ChronosESP32.h"
3535

3636
#define SERVICE_UUID "6e400001-b5a3-f393-e0a9-e50e24dcca9e"
3737
#define CHARACTERISTIC_UUID_RX "6e400002-b5a3-f393-e0a9-e50e24dcca9e"
@@ -41,19 +41,19 @@ static BLECharacteristic *pCharacteristicTX;
4141
static BLECharacteristic *pCharacteristicRX;
4242

4343
/*!
44-
@brief Constructor for Chronos
44+
@brief Constructor for ChronosESP32
4545
*/
46-
Chronos::Chronos()
46+
ChronosESP32::ChronosESP32()
4747
{
4848
connected = false;
4949
}
5050

5151
/*!
52-
@brief Constructor for Chronos
52+
@brief Constructor for ChronosESP32
5353
@param name
5454
Bluetooth name
5555
*/
56-
Chronos::Chronos(String name)
56+
ChronosESP32::ChronosESP32(String name)
5757
{
5858
connected = false;
5959
watchName = name;
@@ -62,7 +62,7 @@ Chronos::Chronos(String name)
6262
/*!
6363
@brief begin
6464
*/
65-
void Chronos::begin()
65+
void ChronosESP32::begin()
6666
{
6767
BLEDevice::init(watchName.c_str());
6868
BLEServer *pServer = BLEDevice::createServer();
@@ -95,7 +95,7 @@ void Chronos::begin()
9595
/*!
9696
@brief loop
9797
*/
98-
void Chronos::loop()
98+
void ChronosESP32::loop()
9999
{
100100
if (connected)
101101
{
@@ -132,15 +132,15 @@ void Chronos::loop()
132132
@param state
133133
new state of logging
134134
*/
135-
void Chronos::setLogging(bool state)
135+
void ChronosESP32::setLogging(bool state)
136136
{
137137
logging = state;
138138
}
139139

140140
/*!
141141
@brief check whether the device is connected
142142
*/
143-
bool Chronos::isConnected()
143+
bool ChronosESP32::isConnected()
144144
{
145145
return connected;
146146
}
@@ -150,22 +150,22 @@ bool Chronos::isConnected()
150150
@param mode
151151
enable or disable state
152152
*/
153-
void Chronos::set24Hour(bool mode){
153+
void ChronosESP32::set24Hour(bool mode){
154154
hour24 = mode;
155155
}
156156

157157
/*!
158158
@brief return the 24 hour mode
159159
*/
160-
bool Chronos::is24Hour()
160+
bool ChronosESP32::is24Hour()
161161
{
162162
return hour24;
163163
}
164164

165165
/*!
166166
@brief return the mac address
167167
*/
168-
String Chronos::getAddress()
168+
String ChronosESP32::getAddress()
169169
{
170170
return address;
171171
}
@@ -175,7 +175,7 @@ String Chronos::getAddress()
175175
@param level
176176
battery level
177177
*/
178-
void Chronos::setBattery(uint8_t level)
178+
void ChronosESP32::setBattery(uint8_t level)
179179
{
180180
if (batteryLevel != level)
181181
{
@@ -187,7 +187,7 @@ void Chronos::setBattery(uint8_t level)
187187
/*!
188188
@brief return the number of notifications in the buffer
189189
*/
190-
int Chronos::getNotificationCount()
190+
int ChronosESP32::getNotificationCount()
191191
{
192192
if (notificationIndex + 1 >= NOTIF_SIZE)
193193
{
@@ -204,7 +204,7 @@ int Chronos::getNotificationCount()
204204
@param index
205205
position of the notification to be returned, at 0 is the latest received
206206
*/
207-
Notification Chronos::getNotificationAt(int index)
207+
Notification ChronosESP32::getNotificationAt(int index)
208208
{
209209
int latestIndex = (notificationIndex - index + NOTIF_SIZE) % NOTIF_SIZE;
210210
return notifications[latestIndex];
@@ -213,7 +213,7 @@ Notification Chronos::getNotificationAt(int index)
213213
/*!
214214
@brief clear the notificaitons
215215
*/
216-
void Chronos::clearNotifications()
216+
void ChronosESP32::clearNotifications()
217217
{
218218
// here we just set the index to -1, existing data at the buffer will be overwritten
219219
// getNotificationCount() will return 0 but getNotificationAt() will return previous existing data
@@ -224,23 +224,23 @@ void Chronos::clearNotifications()
224224
/*!
225225
@brief return the weather count
226226
*/
227-
int Chronos::getWeatherCount()
227+
int ChronosESP32::getWeatherCount()
228228
{
229229
return weatherSize;
230230
}
231231

232232
/*!
233233
@brief return the weather city name
234234
*/
235-
String Chronos::getWeatherCity()
235+
String ChronosESP32::getWeatherCity()
236236
{
237237
return weatherCity;
238238
}
239239

240240
/*!
241241
@brief return the weather update time
242242
*/
243-
String Chronos::getWeatherTime()
243+
String ChronosESP32::getWeatherTime()
244244
{
245245
return weatherTime;
246246
}
@@ -250,7 +250,7 @@ String Chronos::getWeatherTime()
250250
@param index
251251
position of the weather to be returned
252252
*/
253-
Weather Chronos::getWeatherAt(int index)
253+
Weather ChronosESP32::getWeatherAt(int index)
254254
{
255255
return weather[index % WEATHER_SIZE];
256256
}
@@ -260,7 +260,7 @@ Weather Chronos::getWeatherAt(int index)
260260
@param index
261261
position of the alarm to be returned
262262
*/
263-
Alarm Chronos::getAlarm(int index)
263+
Alarm ChronosESP32::getAlarm(int index)
264264
{
265265
return alarms[index % ALARM_SIZE];
266266
}
@@ -272,7 +272,7 @@ Alarm Chronos::getAlarm(int index)
272272
@param alarm
273273
the alarm object
274274
*/
275-
void Chronos::setAlarm(int index, Alarm alarm)
275+
void ChronosESP32::setAlarm(int index, Alarm alarm)
276276
{
277277
alarms[index % ALARM_SIZE] = alarm;
278278
}
@@ -284,7 +284,7 @@ void Chronos::setAlarm(int index, Alarm alarm)
284284
@param length
285285
command length
286286
*/
287-
void Chronos::sendCommand(uint8_t *command, size_t length)
287+
void ChronosESP32::sendCommand(uint8_t *command, size_t length)
288288
{
289289
pCharacteristicTX->setValue(command, length);
290290
pCharacteristicTX->notify();
@@ -296,7 +296,7 @@ void Chronos::sendCommand(uint8_t *command, size_t length)
296296
@param command
297297
music action
298298
*/
299-
void Chronos::musicControl(uint16_t command)
299+
void ChronosESP32::musicControl(uint16_t command)
300300
{
301301
uint8_t musicCmd[] = {0xAB, 0x00, 0x04, 0xFF, (uint8_t)(command >> 8), 0x80,(uint8_t)(command)};
302302
pCharacteristicTX->setValue(musicCmd, 7);
@@ -309,7 +309,7 @@ void Chronos::musicControl(uint16_t command)
309309
@param state
310310
enable or disable state
311311
*/
312-
void Chronos::findPhone(bool state)
312+
void ChronosESP32::findPhone(bool state)
313313
{
314314
findTimer.active = state;
315315
uint8_t c = state ? 0x01 : 0x00;
@@ -322,15 +322,15 @@ void Chronos::findPhone(bool state)
322322
/*!
323323
@brief get the hour based on hour 24 mode
324324
*/
325-
int Chronos::getHourC()
325+
int ChronosESP32::getHourC()
326326
{
327327
return this->getHour(hour24);
328328
}
329329

330330
/*!
331331
@brief get the zero padded hour based on hour 24 mode
332332
*/
333-
String Chronos::getHourZ()
333+
String ChronosESP32::getHourZ()
334334
{
335335
if (hour24){
336336
return this->getTime("%H");
@@ -344,7 +344,7 @@ String Chronos::getHourZ()
344344
@param caps
345345
capital letters mode
346346
*/
347-
String Chronos::getAmPmC(bool caps)
347+
String ChronosESP32::getAmPmC(bool caps)
348348
{
349349
if (hour24){
350350
return "";
@@ -357,31 +357,31 @@ String Chronos::getAmPmC(bool caps)
357357
/*!
358358
@brief set the connection callback
359359
*/
360-
void Chronos::setConnectionCallback(void (*callback)(bool))
360+
void ChronosESP32::setConnectionCallback(void (*callback)(bool))
361361
{
362362
connectionChangeCallback = callback;
363363
}
364364

365365
/*!
366366
@brief set the notification callback
367367
*/
368-
void Chronos::setNotificationCallback(void (*callback)(Notification))
368+
void ChronosESP32::setNotificationCallback(void (*callback)(Notification))
369369
{
370370
notificationReceivedCallback = callback;
371371
}
372372

373373
/*!
374374
@brief set the configuration callback
375375
*/
376-
void Chronos::setConfigurationCallback(void (*callback)(Config, uint32_t, uint32_t))
376+
void ChronosESP32::setConfigurationCallback(void (*callback)(Config, uint32_t, uint32_t))
377377
{
378378
configurationReceivedCallback = callback;
379379
}
380380

381381
/*!
382382
@brief send the info proprerties to the app
383383
*/
384-
void Chronos::sendInfo()
384+
void ChronosESP32::sendInfo()
385385
{
386386
uint8_t infoCmd[] = {0xab, 0x00, 0x11, 0xff, 0x92, 0xc0, 0x01, 0x00, 0x00, 0xfb, 0x1e, 0x40, 0xc0, 0x0e, 0x32, 0x28, 0x00, 0xe2, 0x07, 0x80};
387387
pCharacteristicTX->setValue(infoCmd, 20);
@@ -392,7 +392,7 @@ void Chronos::sendInfo()
392392
/*!
393393
@brief send the battery level
394394
*/
395-
void Chronos::sendBattery()
395+
void ChronosESP32::sendBattery()
396396
{
397397
uint8_t batCmd[] = {0xAB, 0x00, 0x05, 0xFF, 0x91, 0x80, 0x00, batteryLevel};
398398
pCharacteristicTX->setValue(batCmd, 8);
@@ -405,7 +405,7 @@ void Chronos::sendBattery()
405405
@param id
406406
identifier of the app icon
407407
*/
408-
String Chronos::appName(int id)
408+
String ChronosESP32::appName(int id)
409409
{
410410
switch (id)
411411
{
@@ -450,7 +450,7 @@ String Chronos::appName(int id)
450450
case 0x22:
451451
return "WearFit Pro";
452452
case 0xC0:
453-
return "Chronos";
453+
return "ChronosESP32";
454454
default:
455455
return "Message";
456456
}
@@ -462,7 +462,7 @@ String Chronos::appName(int id)
462462
@param pServer
463463
BLE server object
464464
*/
465-
void Chronos::onConnect(BLEServer *pServer)
465+
void ChronosESP32::onConnect(BLEServer *pServer)
466466
{
467467
connected = true;
468468
infoTimer.active = true;
@@ -478,7 +478,7 @@ void Chronos::onConnect(BLEServer *pServer)
478478
@param pServer
479479
BLE server object
480480
*/
481-
void Chronos::onDisconnect(BLEServer *pServer)
481+
void ChronosESP32::onDisconnect(BLEServer *pServer)
482482
{
483483
connected = false;
484484
BLEDevice::startAdvertising();
@@ -493,7 +493,7 @@ void Chronos::onDisconnect(BLEServer *pServer)
493493
@param pCharacteristic
494494
the BLECharacteristic object
495495
*/
496-
void Chronos::onWrite(BLECharacteristic *pCharacteristic)
496+
void ChronosESP32::onWrite(BLECharacteristic *pCharacteristic)
497497
{
498498
std::string pData = pCharacteristic->getValue();
499499
int len = pData.length();

Chronos.h renamed to ChronosESP32.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
3131
*/
3232

33-
#ifndef CHRONOS_H
34-
#define CHRONOS_H
33+
#ifndef CHRONOSESP32_H
34+
#define CHRONOSESP32_H
3535

3636
#include <Arduino.h>
3737
#include <NimBLEDevice.h>
@@ -62,7 +62,7 @@ struct Weather
6262
int temp;
6363
};
6464

65-
struct ChronosTimer
65+
struct ChronosESP32Timer
6666
{
6767
unsigned long time;
6868
long duration = 5000;
@@ -97,12 +97,12 @@ enum Config
9797
CF_WEATHER // weather config (a Weekly) (b City Name) -
9898
};
9999

100-
class Chronos : public BLEServerCallbacks, public BLECharacteristicCallbacks, public ESP32Time
100+
class ChronosESP32 : public BLEServerCallbacks, public BLECharacteristicCallbacks, public ESP32Time
101101
{
102102

103103
public:
104-
Chronos();
105-
Chronos(String name); // set the BLE name
104+
ChronosESP32();
105+
ChronosESP32(String name); // set the BLE name
106106
void begin(); // initializes BLE
107107
void loop(); // handles routine functions
108108
void setLogging(bool state); // to view raw data receive over BLE
@@ -164,8 +164,8 @@ class Chronos : public BLEServerCallbacks, public BLECharacteristicCallbacks, pu
164164

165165
Alarm alarms[ALARM_SIZE];
166166

167-
ChronosTimer infoTimer;
168-
ChronosTimer findTimer;
167+
ChronosESP32Timer infoTimer;
168+
ChronosESP32Timer findTimer;
169169

170170
void (*connectionChangeCallback)(bool) = nullptr;
171171
void (*notificationReceivedCallback)(Notification) = nullptr;

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ Setup your ESP32 as a smartwatch and connect to Chronos app over BLE.
1919
## Functions
2020

2121
```
22-
Chronos();
23-
Chronos(String name); // set the BLE name
22+
ChronosESP32();
23+
ChronosESP32(String name); // set the BLE name
2424
void begin(); // initializes BLE
2525
void loop(); // handles routine functions
2626
void setLogging(bool state); // to view raw data receive over BLE

0 commit comments

Comments
 (0)