comparison Discovery/Src/cv_heartbeat.c @ 1037:2af07aa38531 GasConsumption

Merge with external development branches: Some features have been prepared for integration: Profiles, DMA UART on Firmware part, Bluetooth discovery and messges logging for development phase. All these new function are deactivated by compile switch and may be activated using the configuration.h for testing purpose.
author Ideenmodellierer
date Mon, 15 Sep 2025 21:12:44 +0200
parents 5b913cdaa9dc
children
comparison
equal deleted inserted replaced
1029:e938901f6386 1037:2af07aa38531
1 ///////////////////////////////////////////////////////////////////////////////
2 /// -*- coding: UTF-8 -*-
3 ///
4 /// \file Discovery/Src/cv_heartbeat.c
5 /// \brief providing functionality to connect OSTC to a Polar HC10 heartbeat sensor
6 /// \author heinrichs weikamp gmbh
7 /// \date 03-July-2025
8 ///
9 /// $Id$
10 ///////////////////////////////////////////////////////////////////////////////
11 /// \par Copyright (c) 2014-2025 Heinrichs Weikamp gmbh
12 ///
13 /// This program is free software: you can redistribute it and/or modify
14 /// it under the terms of the GNU General Public License as published by
15 /// the Free Software Foundation, either version 3 of the License, or
16 /// (at your option) any later version.
17 ///
18 /// This program is distributed in the hope that it will be useful,
19 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
20 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 /// GNU General Public License for more details.
22 ///
23 /// You should have received a copy of the GNU General Public License
24 /// along with this program. If not, see <http://www.gnu.org/licenses/>.
25 //////////////////////////////////////////////////////////////////////////////
26
27 #include "configuration.h"
28
29 #ifdef ENABLE_PULSE_SENSOR_BT
30 #include "cv_heartbeat.h"
31 #include "tMenuEdit.h"
32
33 #include "gfx_fonts.h"
34 #include "tHome.h"
35 #include "ostc.h"
36 #include "tComm.h"
37 #include "tInfoLogger.h"
38 #include "stdlib.h"
39
40 static sensorHeartbeat_State_t heartbeatState = SENSOR_HB_OFFLINE;
41
42 static uint8_t OnAction_Heartbeat(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action);
43 static uint32_t startDetection_ms;
44
45 #define MAX_BT_DEVICE 10 /* max number of device which may be handled */
46 static btDdeviceData_t btDeviceList[MAX_BT_DEVICE];
47 static btDeviceService_t curDeviceService[10];
48 static btDeviceCharacteristic_t curDevCharacteristic[10];
49 static btDeviceDescriptor_t curDevDescriptor;
50
51
52 static uint8_t curCharacteristicIndex = 0;
53 static uint8_t curServiceIndex = 0;
54 static uint8_t curBtIndex = 0;
55 static uint8_t connHandle = ' ';
56 static uint8_t evaluateDevIndex = 0xFF;
57 static uint8_t evaluateSrvIndex = 0xFF;
58 static uint8_t evaluateCharIndex = 0xFF;
59
60 static void parsePulseMeasurement(uint8_t* pData, uint8_t length)
61 {
62 uint8_t rawData[10];
63
64 char* enptr;
65 uint8_t flags = 0;
66 uint16_t rr = 0;
67 uint8_t index = 0;
68 uint8_t* pRaw = (uint8_t*)&rawData;
69 char tmpStr[3];
70
71 tmpStr[2] = 0;
72
73 HRMeasurement_t pulseData;
74
75 for(index = 0; index < length; index +=2)
76 {
77 memcpy(tmpStr,&pData[index],2);
78 rawData[index / 2] = strtol(tmpStr, &enptr,16);
79 }
80 flags = pRaw[0];
81 index = 1;
82 /* 0: Heart Rate Format bit (0 = UINT8, 1 = UINT16) */
83 if (flags & 0x01)
84 {
85 pulseData.heart_rate = pRaw[index] | (pRaw[index + 1] << 8);
86 index += 2;
87 } else
88 {
89 pulseData.heart_rate = pRaw[index];
90 index += 1;
91 }
92
93 /* 3: Energy Expended Status */
94 if (flags & 0x08)
95 {
96 pulseData.energy_expended = pRaw[index] | (pRaw[index + 1] << 8);
97 index += 2;
98 } else
99 {
100 pulseData.energy_expended = 0;
101 }
102 /* 4: RR-Interval bit */
103 pulseData.rr_count = 0;
104 if (flags & 0x10)
105 {
106 while (index + 1 < 4 && pulseData.rr_count < 10)
107 {
108 rr = pRaw[index] | (pRaw[index + 1] << 8);
109 pulseData.rr_intervals[pulseData.rr_count++] = rr;
110 index += 2;
111 }
112 }
113 // snprintf(text,40,"Pulse: %d",pulseData.heart_rate);
114 // InfoLogger_writeLine((uint8_t*)text,strlen(text),0);
115 }
116
117 static indicatior_t checkIndicators(uint8_t* pdata)
118 {
119 indicatior_t ret = NO_INDICATOR;
120
121 if(strcmp((char*)pdata,"+UBTD:") == 0)
122 {
123 ret = DEVICE_INDICATOR;
124 }
125 else if(strcmp((char*)pdata,"+UUBTACLC:") == 0)
126 {
127 ret = CONNECTION_INDICATOR;
128 }
129 else if(strcmp((char*)pdata,"+UBTGDP:") == 0)
130 {
131 ret = SERVICE_INDICATOR;
132 }
133 else if(strcmp((char*)pdata,"+UBTGDCS:") == 0)
134 {
135 ret = CHARACTERISTIC_INDICATOR;
136 }
137 else if(strcmp((char*)pdata,"+UBTGDCD:") == 0)
138 {
139 ret = DESCRIPTOR_INDICATOR;
140 }
141 else if(strcmp((char*)pdata,"+UUBTGN:") == 0)
142 {
143 ret = PULSE_INDICATOR;
144 }
145 return ret;
146 }
147
148 static void handleOK()
149 {
150 uint8_t index = 0;
151
152 switch(heartbeatState)
153 {
154 case SENSOR_HB_ENABLE_BLE: heartbeatState = SENSOR_HB_CHECK_CONFIG;
155 break;
156 case SENSOR_HB_CHECK_CONFIG: heartbeatState = SENSOR_HB_DISCOVER;
157 break;
158 case SENSOR_HB_RESTART: heartbeatState = SENSOR_HB_OFFLINE;
159 break;
160 case SENSOR_HB_DISCOVER: if(curBtIndex > 0)
161 {
162 heartbeatState = SENSOR_HB_CONNECT;
163 evaluateDevIndex = 0;
164 }
165 else
166 {
167 heartbeatState = SENSOR_HB_OFFLINE;
168 }
169
170 break;
171 case SENSOR_HB_SERVICES: evaluateSrvIndex = 0xFF;
172 if(curServiceIndex != 0)
173 {
174 for(index = 0; index <= curServiceIndex; index++)
175 {
176 if(strcmp((char*)curDeviceService[index].uuid,"180D") == 0)
177 {
178 heartbeatState = SENSOR_HB_CHARACTERISTIC;
179 evaluateSrvIndex = index;
180 curCharacteristicIndex = 0;
181 break;
182 }
183 }
184 }
185 if(evaluateSrvIndex == 0xFF) /* device does not provide heartbeat data => disconnect */
186 {
187 heartbeatState = SENSOR_HB_DISCONNECT;
188 }
189 break;
190 case SENSOR_HB_CHARACTERISTIC: evaluateCharIndex = 0xFF;
191 if(curCharacteristicIndex != 0)
192 {
193 for(index = 0; index < curCharacteristicIndex; index++)
194 {
195 if(strcmp((char*)curDevCharacteristic[index].uuid,"2A37") == 0)
196 {
197 heartbeatState = SENSOR_HB_DESCRIPTOR;
198 evaluateCharIndex = index;
199 break;
200 }
201 }
202 }
203 if(evaluateCharIndex == 0xFF) /* device does not provide heartbeat data => disconnect */
204 {
205 heartbeatState = SENSOR_HB_DISCONNECT;
206 }
207 break;
208 case SENSOR_HB_DESCRIPTOR: if(strcmp((char*)curDevDescriptor.uuid,"2902") == 0)
209 {
210 heartbeatState = SENSOR_HB_SUBSCRIBE;
211 }
212 else
213 {
214 heartbeatState = SENSOR_HB_DISCONNECT;
215 }
216 break;
217
218 case SENSOR_HB_SUBSCRIBE: heartbeatState = SENSOR_HB_CONNECTED;
219 break;
220 case SENSOR_HB_DISCONNECT: evaluateDevIndex++;
221 connHandle= ' ';
222 if(evaluateDevIndex < curBtIndex) /* more devices to be evaluated? */
223 {
224 heartbeatState = SENSOR_HB_CONNECT;
225 }
226 else
227 {
228 heartbeatState = SENSOR_HB_OFFLINE;
229 }
230 break;
231 case SENSOR_HB_CONNECT: /* handled in data rx section */
232 default:
233 break;
234 }
235 }
236
237 static void handleERROR()
238 {
239 switch(heartbeatState)
240 {
241 case SENSOR_HB_DISCONNECT: evaluateDevIndex++;
242 connHandle= ' ';
243 if(evaluateDevIndex < curBtIndex) /* more devices to be evaluated? */
244 {
245 heartbeatState = SENSOR_HB_CONNECT;
246 }
247 else
248 {
249 heartbeatState = SENSOR_HB_OFFLINE;
250 }
251 break;
252 default:
253 break;
254 }
255 }
256
257 uint8_t cv_heartbeat_HandleData()
258 {
259 static uint8_t firstDevice = 1;
260 static uint8_t curLine[MAX_CHAR_PER_LINE]; /* holds complete line and is used for logging */
261 static uint8_t curLineIndex = 0;
262 static uint8_t parameter[40]; /* content of the parameter in read state */
263 static uint8_t writeIndex = 0;
264 static uint8_t complete = 0;
265
266 static readDataType_t readType = BT_READ_NOTHING;
267
268 uint8_t data = 0;
269 data = UART_getChar();
270
271 while((data != 0) && (complete == 0))
272 {
273 if(curLineIndex == MAX_CHAR_PER_LINE - 1) /* avoid overflow */
274 {
275 InfoLogger_writeLine(curLine,curLineIndex,0);
276 memset(curLine,0,sizeof(curLine));
277 curLineIndex = 0;
278 }
279 if((data == '\r') || (data == '\n'))
280 {
281 if(curLineIndex > 0)
282 {
283 InfoLogger_writeLine(curLine,curLineIndex,0);
284 if(strcmp((char*)curLine,"OK") == 0)
285 {
286 handleOK();
287 }
288 else
289 {
290 if(strcmp((char*)curLine,"ERROR") == 0)
291 {
292 handleERROR();
293 }
294 }
295 }
296 switch(readType)
297 {
298 case BT_READ_DEVICE_NAME: if(writeIndex < BLUEMOD_NAME_SIZE)
299 {
300 memcpy (btDeviceList[curBtIndex].name, parameter, writeIndex);
301 }
302 break;
303 case BT_READ_SERV_UUID: if((writeIndex < 50) && (curServiceIndex < 10))
304 {
305 memcpy(curDeviceService[curServiceIndex].uuid, parameter, writeIndex);
306 }
307 curServiceIndex++;
308 break;
309 case BT_READ_CHAR_UUID: if(writeIndex < 50)
310 {
311 memcpy(curDevCharacteristic[curCharacteristicIndex].uuid, parameter, writeIndex);
312 curCharacteristicIndex++;
313 }
314 break;
315 case BT_READ_DESC_UUID: if(writeIndex < 50)
316 {
317 memcpy(curDevDescriptor.uuid, parameter, writeIndex);
318 }
319 break;
320 case BT_READ_PULSE_DATA: if(writeIndex < 50)
321 {
322 parsePulseMeasurement(parameter, writeIndex);
323 }
324 break;
325 default:
326 break;
327 }
328 curLineIndex = 0;
329 writeIndex = 0;
330 memset(curLine,0,sizeof(curLine));
331 readType = BT_READ_NOTHING;
332 }
333 else
334 {
335 if(curLineIndex < MAX_CHAR_PER_LINE) curLine[curLineIndex++] = data;
336
337 if(data == ':')
338 {
339 switch(checkIndicators(curLine))
340 {
341 case DEVICE_INDICATOR: readType = BT_READ_DEVICE_ADDR;
342 break;
343 case CONNECTION_INDICATOR: readType = BT_READ_CON_DETAILS;
344 break;
345 case SERVICE_INDICATOR: readType = BT_READ_SERV_HANDLE;
346 break;
347 case CHARACTERISTIC_INDICATOR: readType = BT_READ_CHAR_CONHANDLE;
348 break;
349 case DESCRIPTOR_INDICATOR: readType = BT_READ_DESC_CONHANDLE;
350 break;
351 case PULSE_INDICATOR: readType = BT_READ_PULSE_CONHANDLE;
352 break;
353 default:
354 break;
355 }
356 writeIndex = 0;
357 memset(parameter,0,sizeof(parameter));
358 }
359 else
360 {
361 if(data == ',') /* parameter end */
362 {
363 switch(readType)
364 {
365 case BT_READ_DEVICE_ADDR: if(writeIndex < BLUEMOD_ADDR_SIZE-1)
366 {
367 if(firstDevice)
368 {
369 firstDevice = 0;
370 }
371 else
372 {
373 curBtIndex++;
374 }
375 parameter[writeIndex-1] = 0; /*remove 'p' from address */
376 strcpy((char*)btDeviceList[curBtIndex].address, (char*)parameter);
377 }
378 readType = BT_READ_DEVICE_RSSI;
379 break;
380 case BT_READ_DEVICE_RSSI: if(writeIndex < BLUEMOD_RSSI_SIZE-1)
381 {
382 strcpy((char*)btDeviceList[curBtIndex].rssi, (char*)parameter);
383 }
384 readType = BT_READ_DEVICE_NAME;
385 break;
386 case BT_READ_DEVICE_NAME: if(writeIndex < BLUEMOD_NAME_SIZE-1)
387 {
388 memcpy(btDeviceList[curBtIndex].name, parameter, writeIndex);
389 }
390 readType = BT_READ_NOTHING;
391 break;
392 case BT_READ_CON_DETAILS: connHandle = parameter[0];
393 heartbeatState = SENSOR_HB_SERVICES;
394 readType = BT_READ_NOTHING;
395 curServiceIndex = 0;
396 break;
397 case BT_READ_SERV_HANDLE: curDeviceService[curServiceIndex].handle = parameter[0];
398 readType = BT_READ_SERV_START;
399 break;
400 case BT_READ_SERV_START: if(writeIndex < 6)
401 {
402 memcpy(curDeviceService[curServiceIndex].start, parameter, writeIndex);
403 }
404 readType = BT_READ_SERV_END;
405 break;
406 case BT_READ_SERV_END: if(writeIndex < 6)
407 {
408 memcpy(curDeviceService[curServiceIndex].end, parameter, writeIndex);
409 }
410 readType = BT_READ_SERV_UUID;
411 break;
412 case BT_READ_CHAR_CONHANDLE: curDevCharacteristic[curCharacteristicIndex].conHandle = parameter[0];
413 readType = BT_READ_CHAR_ATTRIBUTE;
414 break;
415 case BT_READ_CHAR_ATTRIBUTE: if(writeIndex < 10)
416 {
417 memcpy(curDevCharacteristic[curCharacteristicIndex].attrHandle, parameter, writeIndex);
418 }
419 readType = BT_READ_CHAR_PROPERTY;
420 break;
421 case BT_READ_CHAR_PROPERTY: if(writeIndex < 10)
422 {
423 memcpy(curDevCharacteristic[curCharacteristicIndex].properties, parameter, writeIndex);
424 }
425 readType = BT_READ_CHAR_VALUEHANDLE;
426 break;
427 case BT_READ_CHAR_VALUEHANDLE: if(writeIndex < 10)
428 {
429 memcpy(curDevCharacteristic[curCharacteristicIndex].valueHandle, parameter, writeIndex);
430 }
431 readType = BT_READ_CHAR_UUID;
432 break;
433 case BT_READ_DESC_CONHANDLE: curDevDescriptor.conHandle = parameter[0];
434 readType = BT_READ_DESC_CHARHANDLE;
435 break;
436 case BT_READ_DESC_CHARHANDLE: if(writeIndex < 10)
437 {
438 memcpy(curDevDescriptor.charHandle, parameter, writeIndex);
439 }
440 readType = BT_READ_DESC_DESCHANDLE;
441 break;
442 case BT_READ_DESC_DESCHANDLE: if(writeIndex < 10)
443 {
444 memcpy(curDevDescriptor.descHandle, parameter, writeIndex);
445 }
446 readType = BT_READ_DESC_UUID;
447 break;
448 case BT_READ_PULSE_CONHANDLE: curDevDescriptor.conHandle = parameter[0];
449 readType = BT_READ_PULSE_VALUEHANDLE;
450 break;
451 case BT_READ_PULSE_VALUEHANDLE: if(writeIndex < 10)
452 {
453 // if(strcmp((char*)curDevCharacteristic[evaluateCharIndex].valueHandle,(char*) parameter) == 0)
454 {
455 readType = BT_READ_PULSE_DATA;
456 }
457 #if 0
458 else
459 {
460 readType = BT_READ_NOTHING;
461 }
462 #endif
463 }
464 break;
465 default: readType = BT_READ_NOTHING;
466 break;
467 }
468 writeIndex = 0;
469 memset(parameter,0 , sizeof(parameter));
470 }
471 else
472 {
473 if(readType != BT_READ_NOTHING)
474 {
475 parameter[writeIndex++] = data;
476 }
477 }
478 }
479 }
480 data = UART_getChar();
481 }
482 return complete;
483 }
484
485 sensorHeartbeat_State_t cv_heartbeat_getState()
486 {
487 return heartbeatState;
488 }
489
490 void openEdit_Heartbeat(void)
491 {
492 char text[32];
493 snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_Pulse);
494 write_topline(text);
495
496 set_globalState(StMOption_Heartbeat);
497 resetMenuEdit(CLUT_MenuPageCvOption);
498
499 snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_SensorDetect);
500 write_field_button(StMOption_Heartbeat, 30, 299, ME_Y_LINE1, &FontT48, text);
501
502 write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus);
503
504 setEvent(StMOption_Heartbeat, (uint32_t)OnAction_Heartbeat);
505 }
506
507 static uint8_t OnAction_Heartbeat(uint32_t editId, uint8_t blockNumber, uint8_t digitNumber, uint8_t digitContent, uint8_t action)
508 {
509 switch(heartbeatState)
510 {
511 case SENSOR_HB_OFFLINE:
512 HAL_UART_AbortReceive_IT(&UartHandle);
513 MX_UART_BT_Init_DMA();
514 UART_StartDMARx();
515 heartbeatState = SENSOR_HB_ENABLE_BLE;
516 startDetection_ms = HAL_GetTick();
517 curBtIndex = 0;
518 memset(btDeviceList, 0, sizeof(btDeviceList));
519 break;
520
521 default:
522 break;
523 }
524 return UNSPECIFIC_RETURN;
525 }
526
527 void cv_heartbeat_Control(void)
528 {
529 static uint8_t action = 0;
530 static uint8_t retry = 0;
531 static uint8_t lastState = 0;
532 char cmd[50];
533
534 cmd[0] = 0;
535
536 if(action == 3)
537 {
538 action = 0;
539 switch(heartbeatState)
540 {
541 case SENSOR_HB_ENABLE_BLE: HAL_Delay(1000);
542 snprintf(cmd, sizeof(cmd), "+++" ); //"AT+UBTD=2,1,5000\r\n"
543 InfoLogger_writeLine((uint8_t*)cmd,3,1);
544 HAL_UART_Transmit(&UartHandle, (uint8_t*)cmd, 3, 5000);
545 HAL_Delay(1000);
546 cmd[0] = 0;
547 break;
548 case SENSOR_HB_CHECK_CONFIG: snprintf(cmd, sizeof(cmd), "AT+UBTCFG=2\r\n" ); // AT+UBTLE?
549
550 #if 0
551 if(settingsGetPointer()->dive_mode == DIVEMODE_OC)
552 {
553 snprintf(cmd, sizeof(cmd), "AT+UBTLE=2\r\n" ); //+UBTLE=1 //"AT+UBTD=2,1,5000\r\n"
554 }
555 else
556 {
557 snprintf(cmd, sizeof(cmd), "AT+UBTLE=3\r\n" ); //+UBTLE=1 //"AT+UBTD=2,1,5000\r\n"
558 }
559 #endif
560 break;
561 case SENSOR_HB_DISCOVER: if(lastState != SENSOR_HB_DISCOVER)
562 {
563 snprintf(cmd, sizeof(cmd), "AT+UBTD=2,1\r\n" ); //+UBTLE=1 //"AT+UBTD=2,1,5000\r\n"
564 curBtIndex = 0;
565 }
566
567 //snprintf(cmd, sizeof(cmd), "AT&W\r\n" ); // AT+UBTD=2,1\r\n "AT+UBTD=2,1,5000\r\n"
568 break;
569 #if 0
570 case SENSOR_HB_RESTART: snprintf(cmd, sizeof(cmd), "AT+UBTD=2,1\r\n" ); //+UBTLE=1 //"AT+UBTD=2,1,5000\r\n"
571
572 // snprintf(cmd, sizeof(cmd), "AT+CPWROFF\r\n" ); // AT+UBTD=2,1\r\n "AT+UBTD=2,1,5000\r\n"
573 break;
574 #endif
575 case SENSOR_HB_CONNECT: if(evaluateDevIndex < curBtIndex)
576 {
577 snprintf(cmd, sizeof(cmd), "AT+UBTACLC=%s\r\n",btDeviceList[evaluateDevIndex].address);
578 }
579 break;
580 case SENSOR_HB_DISCONNECT: snprintf(cmd, sizeof(cmd), "AT+UBTACLD=%c\r\n",connHandle);
581 break;
582 case SENSOR_HB_SERVICES: if((connHandle >= '0') && (connHandle <= '9') && (lastState != SENSOR_HB_SERVICES))
583 {
584 snprintf(cmd, sizeof(cmd), "AT+UBTGDP=%c\r\n",connHandle);
585 memset(curDeviceService, 0, sizeof(curDeviceService));
586 }
587 break;
588 case SENSOR_HB_CHARACTERISTIC: snprintf(cmd, sizeof(cmd), "AT+UBTGDCS=%c,%s,%s\r\n",connHandle,curDeviceService[evaluateSrvIndex].start
589 ,curDeviceService[evaluateSrvIndex].end);
590 memset(curDevCharacteristic, 0, sizeof(curDevCharacteristic));
591 break;
592 case SENSOR_HB_DESCRIPTOR: snprintf(cmd, sizeof(cmd), "AT+UBTGDCD=%c,%s,%s\r\n",connHandle,curDevCharacteristic[evaluateCharIndex].valueHandle
593 ,curDeviceService[evaluateSrvIndex].end);
594 break;
595 case SENSOR_HB_SUBSCRIBE: snprintf(cmd, sizeof(cmd), "AT+UBTGWC=%c,%s,1\r\n",connHandle,curDevDescriptor.descHandle);
596 break;
597 default:
598 break;
599 }
600 if(cmd[0] != 0)
601 {
602 {
603 InfoLogger_writeLine((uint8_t*)cmd,strlen(cmd),1);
604 HAL_UART_Transmit(&UartHandle, (uint8_t*)cmd, strlen(cmd), 5000);
605 retry++;
606 if(retry == 3)
607 {
608 heartbeatState = SENSOR_HB_OFFLINE;
609 }
610 }
611 }
612 if(lastState != heartbeatState)
613 {
614 lastState = heartbeatState;
615 retry = 0;
616 }
617 }
618 else
619 {
620 action++;
621 }
622 }
623 void refresh_Heartbeat(void)
624 {
625 char text[32];
626 uint8_t index = 0;
627
628 snprintf(text, 32, "\001%c%c", TXT_2BYTE, TXT2BYTE_Pulse);
629 write_topline(text);
630
631 switch(heartbeatState)
632 {
633 case SENSOR_HB_OFFLINE:
634 default: snprintf(text, 32, "%c%c", TXT_2BYTE, TXT2BYTE_SensorDetect);
635 write_label_var(30, 299, ME_Y_LINE1, &FontT48, text);
636
637 if(curBtIndex > 0)
638 {
639 while((index < curBtIndex) && (index < 3))
640 {
641 snprintf(text, 40, "%s", btDeviceList[index].address);
642 write_label_var( 30, 300, ME_Y_LINE3 + (index * ME_Y_LINE_STEP), &FontT48, text);
643 index++;
644 }
645 }
646 break;
647 case SENSOR_HB_ENABLE_BLE: snprintf(text, 32, "Activate BLE");
648 write_label_var( 30, 300, ME_Y_LINE1, &FontT48, text);
649 break;
650 case SENSOR_HB_DISCOVER:
651 snprintf(text, 32, "Searching");
652 write_label_var( 30, 300, ME_Y_LINE1, &FontT48, text);
653
654 if(curBtIndex > 0)
655 {
656 while((index < curBtIndex) && (index < 4))
657 {
658 snprintf(text, 40, "%s", btDeviceList[index].address);
659 write_label_var( 30, 300, ME_Y_LINE2 + (index * ME_Y_LINE_STEP), &FontT48, text);
660 index++;
661 }
662 }
663 break;
664 }
665
666 write_buttonTextline(TXT2BYTE_ButtonMinus, TXT2BYTE_ButtonEnter, TXT2BYTE_ButtonPlus);
667 }
668 #endif