| 230 | } |
| 231 | |
| 232 | void disPlayBLESend() { |
| 233 | uint8_t senddata[2] = {0}; |
| 234 | tft.fillScreen(bruceConfig.bgColor); |
| 235 | drawMainBorder(); // Moved up to avoid drawing screen issues |
| 236 | tft.setTextSize(1); |
| 237 | |
| 238 | pService->start(); |
| 239 | pServer->getAdvertising()->start(); |
| 240 | |
| 241 | uint64_t chipid = ESP.getEfuseMac(); |
| 242 | String blename = "Bruce-" + String((uint8_t)(chipid >> 32), HEX); |
| 243 | |
| 244 | BLEConnected = true; |
| 245 | |
| 246 | bool wasConnected = false; |
| 247 | bool first_run = true; |
| 248 | while (!check(EscPress)) { |
| 249 | if (deviceConnected) { |
| 250 | if (!wasConnected) { |
| 251 | tft.fillRect(10, 26, tftWidth - 20, tftHeight - 36, TFT_BLACK); |
| 252 | drawBLE_beacon(180, 28, TFT_BLUE); |
| 253 | tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor); |
| 254 | tft.setTextSize(FM); |
| 255 | tft.setCursor(12, 50); |
| 256 | // tft.printf("BLE connect!\n"); |
| 257 | tft.printf("BLE Send\n"); |
| 258 | tft.setTextSize(FM); |
| 259 | } |
| 260 | tft.fillRect(10, 100, tftWidth - 20, 28, TFT_BLACK); |
| 261 | tft.setCursor(12, 100); |
| 262 | if (senddata[0] % 4 == 0) { |
| 263 | tft.printf("0x%02X> ", senddata[0]); |
| 264 | } else if (senddata[0] % 4 == 1) { |
| 265 | tft.printf("0x%02X>> ", senddata[0]); |
| 266 | } else if (senddata[0] % 4 == 2) { |
| 267 | tft.printf("0x%02X >> ", senddata[0]); |
| 268 | } else if (senddata[0] % 4 == 3) { |
| 269 | tft.printf("0x%02X > ", senddata[0]); |
| 270 | } |
| 271 | |
| 272 | senddata[1]++; |
| 273 | if (senddata[1] > 3) { |
| 274 | senddata[1] = 0; |
| 275 | senddata[0]++; |
| 276 | pTxCharacteristic->setValue(senddata, 1); |
| 277 | pTxCharacteristic->notify(); |
| 278 | } |
| 279 | wasConnected = true; |
| 280 | } else { |
| 281 | if (wasConnected or first_run) { |
| 282 | first_run = false; |
| 283 | tft.fillRect(10, 26, tftWidth - 20, tftHeight - 36, TFT_BLACK); |
| 284 | tft.setTextSize(FM); |
| 285 | tft.setCursor(12, 50); |
| 286 | tft.setTextColor(TFT_RED); |
| 287 | tft.printf("BLE disconnect\n"); |
| 288 | tft.setCursor(12, 75); |
| 289 | tft.setTextColor(tft.color565(18, 150, 219)); |
no test coverage detected