31
31
*/
32
32
33
33
#include < Arduino.h>
34
- #include " Chronos .h"
34
+ #include " ChronosESP32 .h"
35
35
36
36
#define SERVICE_UUID " 6e400001-b5a3-f393-e0a9-e50e24dcca9e"
37
37
#define CHARACTERISTIC_UUID_RX " 6e400002-b5a3-f393-e0a9-e50e24dcca9e"
@@ -41,19 +41,19 @@ static BLECharacteristic *pCharacteristicTX;
41
41
static BLECharacteristic *pCharacteristicRX;
42
42
43
43
/* !
44
- @brief Constructor for Chronos
44
+ @brief Constructor for ChronosESP32
45
45
*/
46
- Chronos::Chronos ()
46
+ ChronosESP32::ChronosESP32 ()
47
47
{
48
48
connected = false ;
49
49
}
50
50
51
51
/* !
52
- @brief Constructor for Chronos
52
+ @brief Constructor for ChronosESP32
53
53
@param name
54
54
Bluetooth name
55
55
*/
56
- Chronos::Chronos (String name)
56
+ ChronosESP32::ChronosESP32 (String name)
57
57
{
58
58
connected = false ;
59
59
watchName = name;
@@ -62,7 +62,7 @@ Chronos::Chronos(String name)
62
62
/* !
63
63
@brief begin
64
64
*/
65
- void Chronos ::begin ()
65
+ void ChronosESP32 ::begin ()
66
66
{
67
67
BLEDevice::init (watchName.c_str ());
68
68
BLEServer *pServer = BLEDevice::createServer ();
@@ -95,7 +95,7 @@ void Chronos::begin()
95
95
/* !
96
96
@brief loop
97
97
*/
98
- void Chronos ::loop ()
98
+ void ChronosESP32 ::loop ()
99
99
{
100
100
if (connected)
101
101
{
@@ -132,15 +132,15 @@ void Chronos::loop()
132
132
@param state
133
133
new state of logging
134
134
*/
135
- void Chronos ::setLogging (bool state)
135
+ void ChronosESP32 ::setLogging (bool state)
136
136
{
137
137
logging = state;
138
138
}
139
139
140
140
/* !
141
141
@brief check whether the device is connected
142
142
*/
143
- bool Chronos ::isConnected ()
143
+ bool ChronosESP32 ::isConnected ()
144
144
{
145
145
return connected;
146
146
}
@@ -150,22 +150,22 @@ bool Chronos::isConnected()
150
150
@param mode
151
151
enable or disable state
152
152
*/
153
- void Chronos ::set24Hour (bool mode){
153
+ void ChronosESP32 ::set24Hour (bool mode){
154
154
hour24 = mode;
155
155
}
156
156
157
157
/* !
158
158
@brief return the 24 hour mode
159
159
*/
160
- bool Chronos ::is24Hour ()
160
+ bool ChronosESP32 ::is24Hour ()
161
161
{
162
162
return hour24;
163
163
}
164
164
165
165
/* !
166
166
@brief return the mac address
167
167
*/
168
- String Chronos ::getAddress ()
168
+ String ChronosESP32 ::getAddress ()
169
169
{
170
170
return address;
171
171
}
@@ -175,7 +175,7 @@ String Chronos::getAddress()
175
175
@param level
176
176
battery level
177
177
*/
178
- void Chronos ::setBattery (uint8_t level)
178
+ void ChronosESP32 ::setBattery (uint8_t level)
179
179
{
180
180
if (batteryLevel != level)
181
181
{
@@ -187,7 +187,7 @@ void Chronos::setBattery(uint8_t level)
187
187
/* !
188
188
@brief return the number of notifications in the buffer
189
189
*/
190
- int Chronos ::getNotificationCount ()
190
+ int ChronosESP32 ::getNotificationCount ()
191
191
{
192
192
if (notificationIndex + 1 >= NOTIF_SIZE)
193
193
{
@@ -204,7 +204,7 @@ int Chronos::getNotificationCount()
204
204
@param index
205
205
position of the notification to be returned, at 0 is the latest received
206
206
*/
207
- Notification Chronos ::getNotificationAt (int index)
207
+ Notification ChronosESP32 ::getNotificationAt (int index)
208
208
{
209
209
int latestIndex = (notificationIndex - index + NOTIF_SIZE) % NOTIF_SIZE;
210
210
return notifications[latestIndex];
@@ -213,7 +213,7 @@ Notification Chronos::getNotificationAt(int index)
213
213
/* !
214
214
@brief clear the notificaitons
215
215
*/
216
- void Chronos ::clearNotifications ()
216
+ void ChronosESP32 ::clearNotifications ()
217
217
{
218
218
// here we just set the index to -1, existing data at the buffer will be overwritten
219
219
// getNotificationCount() will return 0 but getNotificationAt() will return previous existing data
@@ -224,23 +224,23 @@ void Chronos::clearNotifications()
224
224
/* !
225
225
@brief return the weather count
226
226
*/
227
- int Chronos ::getWeatherCount ()
227
+ int ChronosESP32 ::getWeatherCount ()
228
228
{
229
229
return weatherSize;
230
230
}
231
231
232
232
/* !
233
233
@brief return the weather city name
234
234
*/
235
- String Chronos ::getWeatherCity ()
235
+ String ChronosESP32 ::getWeatherCity ()
236
236
{
237
237
return weatherCity;
238
238
}
239
239
240
240
/* !
241
241
@brief return the weather update time
242
242
*/
243
- String Chronos ::getWeatherTime ()
243
+ String ChronosESP32 ::getWeatherTime ()
244
244
{
245
245
return weatherTime;
246
246
}
@@ -250,7 +250,7 @@ String Chronos::getWeatherTime()
250
250
@param index
251
251
position of the weather to be returned
252
252
*/
253
- Weather Chronos ::getWeatherAt (int index)
253
+ Weather ChronosESP32 ::getWeatherAt (int index)
254
254
{
255
255
return weather[index % WEATHER_SIZE];
256
256
}
@@ -260,7 +260,7 @@ Weather Chronos::getWeatherAt(int index)
260
260
@param index
261
261
position of the alarm to be returned
262
262
*/
263
- Alarm Chronos ::getAlarm (int index)
263
+ Alarm ChronosESP32 ::getAlarm (int index)
264
264
{
265
265
return alarms[index % ALARM_SIZE];
266
266
}
@@ -272,7 +272,7 @@ Alarm Chronos::getAlarm(int index)
272
272
@param alarm
273
273
the alarm object
274
274
*/
275
- void Chronos ::setAlarm (int index, Alarm alarm)
275
+ void ChronosESP32 ::setAlarm (int index, Alarm alarm)
276
276
{
277
277
alarms[index % ALARM_SIZE] = alarm;
278
278
}
@@ -284,7 +284,7 @@ void Chronos::setAlarm(int index, Alarm alarm)
284
284
@param length
285
285
command length
286
286
*/
287
- void Chronos ::sendCommand (uint8_t *command, size_t length)
287
+ void ChronosESP32 ::sendCommand (uint8_t *command, size_t length)
288
288
{
289
289
pCharacteristicTX->setValue (command, length);
290
290
pCharacteristicTX->notify ();
@@ -296,7 +296,7 @@ void Chronos::sendCommand(uint8_t *command, size_t length)
296
296
@param command
297
297
music action
298
298
*/
299
- void Chronos ::musicControl (uint16_t command)
299
+ void ChronosESP32 ::musicControl (uint16_t command)
300
300
{
301
301
uint8_t musicCmd[] = {0xAB , 0x00 , 0x04 , 0xFF , (uint8_t )(command >> 8 ), 0x80 ,(uint8_t )(command)};
302
302
pCharacteristicTX->setValue (musicCmd, 7 );
@@ -309,7 +309,7 @@ void Chronos::musicControl(uint16_t command)
309
309
@param state
310
310
enable or disable state
311
311
*/
312
- void Chronos ::findPhone (bool state)
312
+ void ChronosESP32 ::findPhone (bool state)
313
313
{
314
314
findTimer.active = state;
315
315
uint8_t c = state ? 0x01 : 0x00 ;
@@ -322,15 +322,15 @@ void Chronos::findPhone(bool state)
322
322
/* !
323
323
@brief get the hour based on hour 24 mode
324
324
*/
325
- int Chronos ::getHourC ()
325
+ int ChronosESP32 ::getHourC ()
326
326
{
327
327
return this ->getHour (hour24);
328
328
}
329
329
330
330
/* !
331
331
@brief get the zero padded hour based on hour 24 mode
332
332
*/
333
- String Chronos ::getHourZ ()
333
+ String ChronosESP32 ::getHourZ ()
334
334
{
335
335
if (hour24){
336
336
return this ->getTime (" %H" );
@@ -344,7 +344,7 @@ String Chronos::getHourZ()
344
344
@param caps
345
345
capital letters mode
346
346
*/
347
- String Chronos ::getAmPmC (bool caps)
347
+ String ChronosESP32 ::getAmPmC (bool caps)
348
348
{
349
349
if (hour24){
350
350
return " " ;
@@ -357,31 +357,31 @@ String Chronos::getAmPmC(bool caps)
357
357
/* !
358
358
@brief set the connection callback
359
359
*/
360
- void Chronos ::setConnectionCallback (void (*callback)(bool ))
360
+ void ChronosESP32 ::setConnectionCallback (void (*callback)(bool ))
361
361
{
362
362
connectionChangeCallback = callback;
363
363
}
364
364
365
365
/* !
366
366
@brief set the notification callback
367
367
*/
368
- void Chronos ::setNotificationCallback (void (*callback)(Notification))
368
+ void ChronosESP32 ::setNotificationCallback (void (*callback)(Notification))
369
369
{
370
370
notificationReceivedCallback = callback;
371
371
}
372
372
373
373
/* !
374
374
@brief set the configuration callback
375
375
*/
376
- void Chronos ::setConfigurationCallback (void (*callback)(Config, uint32_t , uint32_t ))
376
+ void ChronosESP32 ::setConfigurationCallback (void (*callback)(Config, uint32_t , uint32_t ))
377
377
{
378
378
configurationReceivedCallback = callback;
379
379
}
380
380
381
381
/* !
382
382
@brief send the info proprerties to the app
383
383
*/
384
- void Chronos ::sendInfo ()
384
+ void ChronosESP32 ::sendInfo ()
385
385
{
386
386
uint8_t infoCmd[] = {0xab , 0x00 , 0x11 , 0xff , 0x92 , 0xc0 , 0x01 , 0x00 , 0x00 , 0xfb , 0x1e , 0x40 , 0xc0 , 0x0e , 0x32 , 0x28 , 0x00 , 0xe2 , 0x07 , 0x80 };
387
387
pCharacteristicTX->setValue (infoCmd, 20 );
@@ -392,7 +392,7 @@ void Chronos::sendInfo()
392
392
/* !
393
393
@brief send the battery level
394
394
*/
395
- void Chronos ::sendBattery ()
395
+ void ChronosESP32 ::sendBattery ()
396
396
{
397
397
uint8_t batCmd[] = {0xAB , 0x00 , 0x05 , 0xFF , 0x91 , 0x80 , 0x00 , batteryLevel};
398
398
pCharacteristicTX->setValue (batCmd, 8 );
@@ -405,7 +405,7 @@ void Chronos::sendBattery()
405
405
@param id
406
406
identifier of the app icon
407
407
*/
408
- String Chronos ::appName (int id)
408
+ String ChronosESP32 ::appName (int id)
409
409
{
410
410
switch (id)
411
411
{
@@ -450,7 +450,7 @@ String Chronos::appName(int id)
450
450
case 0x22 :
451
451
return " WearFit Pro" ;
452
452
case 0xC0 :
453
- return " Chronos " ;
453
+ return " ChronosESP32 " ;
454
454
default :
455
455
return " Message" ;
456
456
}
@@ -462,7 +462,7 @@ String Chronos::appName(int id)
462
462
@param pServer
463
463
BLE server object
464
464
*/
465
- void Chronos ::onConnect (BLEServer *pServer)
465
+ void ChronosESP32 ::onConnect (BLEServer *pServer)
466
466
{
467
467
connected = true ;
468
468
infoTimer.active = true ;
@@ -478,7 +478,7 @@ void Chronos::onConnect(BLEServer *pServer)
478
478
@param pServer
479
479
BLE server object
480
480
*/
481
- void Chronos ::onDisconnect (BLEServer *pServer)
481
+ void ChronosESP32 ::onDisconnect (BLEServer *pServer)
482
482
{
483
483
connected = false ;
484
484
BLEDevice::startAdvertising ();
@@ -493,7 +493,7 @@ void Chronos::onDisconnect(BLEServer *pServer)
493
493
@param pCharacteristic
494
494
the BLECharacteristic object
495
495
*/
496
- void Chronos ::onWrite (BLECharacteristic *pCharacteristic)
496
+ void ChronosESP32 ::onWrite (BLECharacteristic *pCharacteristic)
497
497
{
498
498
std::string pData = pCharacteristic->getValue ();
499
499
int len = pData.length ();
0 commit comments