MCPcopy Create free account
hub / github.com/cifertech/nRFBox / toggleAdvertising

Function toggleAdvertising

nRFBox_V2/spoofer.cpp:414–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

412}
413
414void 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
468void spooferSetup() {

Callers

nothing calls this directly

Calls 3

setNeoPixelColourFunction · 0.85
getAdvertismentDataFunction · 0.85
updateDisplayFunction · 0.70

Tested by

no test coverage detected