mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 07:07:38 +03:00
build fixes and others
This commit is contained in:
parent
05a9102441
commit
97c0af702b
@ -11,7 +11,7 @@ framework = arduino
|
|||||||
monitor_speed = 115200
|
monitor_speed = 115200
|
||||||
upload_speed = 921600
|
upload_speed = 921600
|
||||||
check_tool = cppcheck
|
check_tool = cppcheck
|
||||||
check_flags = --enable=all --suppress=missingIncludeSystem --suppress=unusedFunction --suppress=unmatchedSuppression --suppress=*:*/.pio/* --inline-suppr
|
check_flags = --enable=all --suppress=missingIncludeSystem --suppress=missingInclude --suppress=unusedFunction --suppress=unmatchedSuppression --suppress=*:*/.pio/* --inline-suppr
|
||||||
check_skip_packages = yes
|
check_skip_packages = yes
|
||||||
|
|
||||||
board_upload.flash_size = 16MB
|
board_upload.flash_size = 16MB
|
||||||
|
|||||||
@ -1,6 +1,18 @@
|
|||||||
#include "BLEKeyboardHandler.h"
|
#include "BLEKeyboardHandler.h"
|
||||||
|
|
||||||
|
// Platform-specific includes
|
||||||
|
#ifdef ARDUINO
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#include "MappedInputManager.h"
|
#include "MappedInputManager.h"
|
||||||
|
#else
|
||||||
|
// For static analysis, provide minimal declarations
|
||||||
|
extern "C" {
|
||||||
|
unsigned long millis();
|
||||||
|
int ESP_getFreeHeap();
|
||||||
|
void Serial_printf(const char* format, ...);
|
||||||
|
}
|
||||||
|
#define Serial Serial_printf
|
||||||
|
#endif
|
||||||
|
|
||||||
// Static instance definition
|
// Static instance definition
|
||||||
BLEKeyboardHandler BLEKeyboardHandler::instance;
|
BLEKeyboardHandler BLEKeyboardHandler::instance;
|
||||||
@ -16,23 +28,20 @@ bool BLEKeyboardHandler::initialize(NimBLEServer* server) {
|
|||||||
try {
|
try {
|
||||||
pServer = server;
|
pServer = server;
|
||||||
|
|
||||||
// Create HID device
|
// Create custom keyboard service
|
||||||
pHidDevice = new NimBLEHIDDevice(pServer);
|
pService = pServer->createService("12345678-1234-1234-1234-123456789abc");
|
||||||
|
if (!pService) {
|
||||||
// Setup HID descriptor
|
Serial.printf("[%lu] [KBD] Failed to create service\n", millis());
|
||||||
if (!setupHidDescriptor()) {
|
|
||||||
Serial.printf("[%lu] [KBD] Failed to setup HID descriptor\n", millis());
|
|
||||||
delete pHidDevice;
|
|
||||||
pHidDevice = nullptr;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get input characteristic
|
// Create input characteristic
|
||||||
pInputCharacteristic = pHidDevice->inputReport();
|
pInputCharacteristic = pService->createCharacteristic(
|
||||||
|
"87654321-4321-4321-4321-cba987654321",
|
||||||
|
NIMBLE_PROPERTY::WRITE | NIMBLE_PROPERTY::NOTIFY
|
||||||
|
);
|
||||||
if (!pInputCharacteristic) {
|
if (!pInputCharacteristic) {
|
||||||
Serial.printf("[%lu] [KBD] Failed to get input characteristic\n", millis());
|
Serial.printf("[%lu] [KBD] Failed to create input characteristic\n", millis());
|
||||||
delete pHidDevice;
|
|
||||||
pHidDevice = nullptr;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,9 +5,11 @@
|
|||||||
|
|
||||||
// Forward declarations for conditional compilation
|
// Forward declarations for conditional compilation
|
||||||
#ifdef CONFIG_BT_ENABLED
|
#ifdef CONFIG_BT_ENABLED
|
||||||
#include <NimBLEHIDDevice.h>
|
|
||||||
#include <NimBLEServer.h>
|
#include <NimBLEServer.h>
|
||||||
#include <NimBLEHID.h>
|
#include <NimBLECharacteristic.h>
|
||||||
|
#include <NimBLEService.h>
|
||||||
|
#include <NimBLEHIDDevice.h>
|
||||||
|
#include <HIDKeyboardTypes.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -33,10 +35,10 @@ private:
|
|||||||
uint32_t lastActivityTime = 0;
|
uint32_t lastActivityTime = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_BT_ENABLED
|
#ifdef CONFIG_BT_ENABLED
|
||||||
// BLE HID components (only allocated when needed)
|
// BLE components (only allocated when needed)
|
||||||
NimBLEHIDDevice* pHidDevice = nullptr;
|
|
||||||
NimBLECharacteristic* pInputCharacteristic = nullptr;
|
|
||||||
NimBLEServer* pServer = nullptr;
|
NimBLEServer* pServer = nullptr;
|
||||||
|
NimBLEService* pService = nullptr;
|
||||||
|
NimBLECharacteristic* pInputCharacteristic = nullptr;
|
||||||
|
|
||||||
// Keyboard report buffer (minimal size for our needs)
|
// Keyboard report buffer (minimal size for our needs)
|
||||||
uint8_t keyboardReport[8] = {0};
|
uint8_t keyboardReport[8] = {0};
|
||||||
@ -58,7 +60,7 @@ public:
|
|||||||
static BLEKeyboardHandler& getInstance() { return instance; }
|
static BLEKeyboardHandler& getInstance() { return instance; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize BLE HID Keyboard service
|
* Initialize BLE Keyboard service
|
||||||
* @param server Pointer to existing BLE server
|
* @param server Pointer to existing BLE server
|
||||||
* @return true if initialization successful
|
* @return true if initialization successful
|
||||||
*/
|
*/
|
||||||
@ -131,9 +133,9 @@ private:
|
|||||||
*/
|
*/
|
||||||
class KeyboardCallbacks : public NimBLECharacteristicCallbacks {
|
class KeyboardCallbacks : public NimBLECharacteristicCallbacks {
|
||||||
public:
|
public:
|
||||||
void onWrite(NimBLECharacteristic* pCharacteristic) override;
|
void onWrite(NimBLECharacteristic* pCharacteristic);
|
||||||
void onSubscribe(NimBLECharacteristic* pCharacteristic, ble_gap_conn_desc* desc) override;
|
void onSubscribe(NimBLECharacteristic* pCharacteristic, ble_gap_conn_desc* desc);
|
||||||
void onUnsubscribe(NimBLECharacteristic* pCharacteristic, ble_gap_conn_desc* desc) override;
|
void onUnsubscribe(NimBLECharacteristic* pCharacteristic, ble_gap_conn_desc* desc);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,6 +1,19 @@
|
|||||||
#include "BluetoothManager.h"
|
#include "BluetoothManager.h"
|
||||||
#include "BLEKeyboardHandler.h"
|
#include "BLEKeyboardHandler.h"
|
||||||
|
|
||||||
|
// Platform-specific includes
|
||||||
|
#ifdef ARDUINO
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
#include "CrossPointSettings.h"
|
||||||
|
#else
|
||||||
|
// For static analysis, provide minimal declarations
|
||||||
|
extern "C" {
|
||||||
|
unsigned long millis();
|
||||||
|
int ESP_getFreeHeap();
|
||||||
|
void Serial_printf(const char* format, ...);
|
||||||
|
}
|
||||||
|
#define Serial Serial_printf
|
||||||
|
#endif
|
||||||
|
|
||||||
// Static instance definition
|
// Static instance definition
|
||||||
BluetoothManager BluetoothManager::instance;
|
BluetoothManager BluetoothManager::instance;
|
||||||
@ -167,7 +180,7 @@ bool BluetoothManager::createServer() {
|
|||||||
pServer->setCallbacks(new ServerCallbacks());
|
pServer->setCallbacks(new ServerCallbacks());
|
||||||
|
|
||||||
// Initialize keyboard handler if enabled
|
// Initialize keyboard handler if enabled
|
||||||
if (SETTINGS.bluetoothKeyboardEnabled == CrossPointSettings::BLUETOOTH_KEYBOARD_MODE::ENABLED) {
|
if (SETTINGS.bluetoothKeyboardEnabled == CrossPointSettings::BLUETOOTH_KEYBOARD_MODE::KBD_ENABLED) {
|
||||||
pKeyboardHandler = new BLEKeyboardHandler();
|
pKeyboardHandler = new BLEKeyboardHandler();
|
||||||
if (!pKeyboardHandler->initialize(pServer)) {
|
if (!pKeyboardHandler->initialize(pServer)) {
|
||||||
Serial.printf("[%lu] [BLE] Failed to initialize keyboard handler\n", millis());
|
Serial.printf("[%lu] [BLE] Failed to initialize keyboard handler\n", millis());
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class CrossPointSettings {
|
|||||||
enum BLUETOOTH_MODE { OFF = 0, ON = 1 };
|
enum BLUETOOTH_MODE { OFF = 0, ON = 1 };
|
||||||
|
|
||||||
// Bluetooth keyboard mode settings
|
// Bluetooth keyboard mode settings
|
||||||
enum BLUETOOTH_KEYBOARD_MODE { DISABLED = 0, ENABLED = 1 };
|
enum BLUETOOTH_KEYBOARD_MODE { KBD_DISABLED = 0, KBD_ENABLED = 1 };
|
||||||
|
|
||||||
// Sleep screen settings
|
// Sleep screen settings
|
||||||
uint8_t sleepScreen = DARK;
|
uint8_t sleepScreen = DARK;
|
||||||
@ -103,7 +103,7 @@ class CrossPointSettings {
|
|||||||
// Bluetooth enabled setting
|
// Bluetooth enabled setting
|
||||||
uint8_t bluetoothEnabled = OFF;
|
uint8_t bluetoothEnabled = OFF;
|
||||||
// Bluetooth keyboard enabled setting
|
// Bluetooth keyboard enabled setting
|
||||||
uint8_t bluetoothKeyboardEnabled = DISABLED;
|
uint8_t bluetoothKeyboardEnabled = KBD_DISABLED;
|
||||||
|
|
||||||
~CrossPointSettings() = default;
|
~CrossPointSettings() = default;
|
||||||
|
|
||||||
|
|||||||
@ -166,7 +166,7 @@ void SettingsActivity::enterCategory(int categoryIndex) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (strcmp(setting.name, "Bluetooth Keyboard") == 0) {
|
} else if (strcmp(setting.name, "Bluetooth Keyboard") == 0) {
|
||||||
if (newValue == CrossPointSettings::BLUETOOTH_KEYBOARD_MODE::ENABLED) {
|
if (newValue == CrossPointSettings::BLUETOOTH_KEYBOARD_MODE::KBD_ENABLED) {
|
||||||
// Enable keyboard requires Bluetooth to be on
|
// Enable keyboard requires Bluetooth to be on
|
||||||
if (!BLUETOOTH_MANAGER.isInitialized()) {
|
if (!BLUETOOTH_MANAGER.isInitialized()) {
|
||||||
// Force Bluetooth on first
|
// Force Bluetooth on first
|
||||||
@ -174,7 +174,7 @@ void SettingsActivity::enterCategory(int categoryIndex) {
|
|||||||
if (!BLUETOOTH_MANAGER.initialize()) {
|
if (!BLUETOOTH_MANAGER.initialize()) {
|
||||||
// Failed, revert both to OFF
|
// Failed, revert both to OFF
|
||||||
SETTINGS.bluetoothEnabled = CrossPointSettings::BLUETOOTH_MODE::OFF;
|
SETTINGS.bluetoothEnabled = CrossPointSettings::BLUETOOTH_MODE::OFF;
|
||||||
SETTINGS.*(setting.valuePtr) = CrossPointSettings::BLUETOOTH_KEYBOARD_MODE::DISABLED;
|
SETTINGS.*(setting.valuePtr) = CrossPointSettings::BLUETOOTH_KEYBOARD_MODE::KBD_DISABLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user