| 3409 | }; |
| 3410 | |
| 3411 | class BluetoothSniffer { |
| 3412 | private: |
| 3413 | DeviceInfo devices[MAX_DEVICES]; |
| 3414 | DisplayLine displayLines[MAX_LINES]; |
| 3415 | int deviceCount = 0; |
| 3416 | int lineNumber = 1; |
| 3417 | int suspiciousCount = 0; |
| 3418 | int newDevicesThisScan = 0; |
| 3419 | int lastDeviceCount = -1; |
| 3420 | int lastSuspiciousCount = -1; |
| 3421 | bool scanning = true; |
| 3422 | bool isBLEScanActive = true; |
| 3423 | unsigned long lastScanTime = 0; |
| 3424 | unsigned long lastFlashToggle = 0; |
| 3425 | bool flashState = false; |
| 3426 | BLEScan* pBLEScan = nullptr; |
| 3427 | BLEAdvertisedDeviceCallbacks* bleDeviceCallbacks = nullptr; |
| 3428 | static BluetoothSniffer* snifferInstance; |
| 3429 | |
| 3430 | void releaseBleCallbacks() { |
| 3431 | if (pBLEScan) { |
| 3432 | pBLEScan->stop(); |
| 3433 | pBLEScan->setAdvertisedDeviceCallbacks(nullptr); |
| 3434 | } |
| 3435 | delete bleDeviceCallbacks; |
| 3436 | bleDeviceCallbacks = nullptr; |
| 3437 | } |
| 3438 | |
| 3439 | static int snifferContentTop() { |
| 3440 | return Y_OFFSET + HEADER_HEIGHT; |
| 3441 | } |
| 3442 | |
| 3443 | static int snifferVisibleLines() { |
| 3444 | return bleMaxLinesInZone(snifferContentTop(), LINE_HEIGHT); |
| 3445 | } |
| 3446 | |
| 3447 | static bool snifferLineFits(int lineIndex) { |
| 3448 | const int y = snifferContentTop() + (lineIndex * LINE_HEIGHT); |
| 3449 | return y + LINE_HEIGHT <= bleContentBottom(); |
| 3450 | } |
| 3451 | |
| 3452 | void initDisplay() { |
| 3453 | uiDrawn = false; |
| 3454 | |
| 3455 | float currentBatteryVoltage = readBatteryVoltage(); |
| 3456 | drawStatusBar(currentBatteryVoltage, true); |
| 3457 | runUI(); |
| 3458 | |
| 3459 | setupTouchscreen(); |
| 3460 | { |
| 3461 | const int bodyH = bleContentBottom() - 37; |
| 3462 | if (bodyH > 0) { |
| 3463 | tft.fillRect(0, 37, 240, bodyH, TFT_BLACK); |
| 3464 | } |
| 3465 | } |
| 3466 | tft.setTextSize(1); |
| 3467 | updateHeader(); |
| 3468 |
nothing calls this directly
no outgoing calls
no test coverage detected