| 412 | } |
| 413 | |
| 414 | void toggleAdvertising() { |
| 415 | |
| 416 | setNeoPixelColour("0"); |
| 417 | |
| 418 | isAdvertising = !isAdvertising; |
| 419 | |
| 420 | if (!isAdvertising) { |
| 421 | pAdvertising->stop(); |
| 422 | setNeoPixelColour("red"); |
| 423 | Serial.println("Advertising stopped."); |
| 424 | updateDisplay(); |
| 425 | } |
| 426 | if (isAdvertising) { |
| 427 | setNeoPixelColour("0"); |
| 428 | if (attack_state == 1) { |
| 429 | esp_bd_addr_t dummy_addr = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; |
| 430 | for (int i = 0; i < 6; i++) { |
| 431 | dummy_addr[i] = random(256); |
| 432 | if (i == 0) { |
| 433 | dummy_addr[i] |= 0xF0; |
| 434 | } |
| 435 | } |
| 436 | // selectDevice(selectedPacket); |
| 437 | |
| 438 | BLEAdvertisementData oAdvertisementData = getAdvertismentData(); |
| 439 | |
| 440 | pAdvertising->setDeviceAddress(dummy_addr, BLE_ADDR_TYPE_RANDOM); |
| 441 | pAdvertising->addServiceUUID(devices_uuid); |
| 442 | pAdvertising->setAdvertisementData(oAdvertisementData); |
| 443 | |
| 444 | pAdvertising->setMinInterval(0x20); |
| 445 | pAdvertising->setMaxInterval(0x20); |
| 446 | pAdvertising->setMinPreferred(0x20); |
| 447 | pAdvertising->setMaxPreferred(0x20); |
| 448 | |
| 449 | pAdvertising->start(); |
| 450 | delay(delayMillisecond); // delay for delayMillisecond ms |
| 451 | pAdvertising->stop(); |
| 452 | } |
| 453 | |
| 454 | Serial.println("Advertising started."); |
| 455 | updateDisplay(); |
| 456 | |
| 457 | if (digitalRead(advControlPin) == LOW) { |
| 458 | delay(50); // Debounce delay |
| 459 | isAdvertising = !isAdvertising; |
| 460 | updateDisplay(); |
| 461 | //break; |
| 462 | } |
| 463 | } |
| 464 | //isAdvertising = !isAdvertising; |
| 465 | } |
| 466 | |
| 467 | |
| 468 | void spooferSetup() { |
nothing calls this directly
no test coverage detected