add test unitaire
This commit is contained in:
52
test_bluetooth.cpp
Normal file
52
test_bluetooth.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <BleCompositeHID.h>
|
||||
#include <GamepadDevice.h>
|
||||
|
||||
BleCompositeHID compositeHID("Modulx Controller V4", "Nono", 100);
|
||||
GamepadDevice gamepad;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(1000);
|
||||
|
||||
Serial.println();
|
||||
Serial.println("===== TEST BLE COMPOSITE HID =====");
|
||||
|
||||
compositeHID.addDevice(&gamepad);
|
||||
compositeHID.begin();
|
||||
|
||||
Serial.println("BLE demarre.");
|
||||
Serial.println("Nom Bluetooth : Modulx Controller V4");
|
||||
Serial.println(" AHHHHHHH Essaie de l'appairer");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
static bool lastConnected = false;
|
||||
bool connected = compositeHID.isConnected();
|
||||
|
||||
if (connected != lastConnected) {
|
||||
if (connected) {
|
||||
Serial.println("[BLE] Connecte !");
|
||||
} else {
|
||||
Serial.println("[BLE] Deconnecte.");
|
||||
}
|
||||
|
||||
lastConnected = connected;
|
||||
}
|
||||
|
||||
if (connected) {
|
||||
Serial.println("[BLE] Test bouton 1");
|
||||
|
||||
gamepad.press(1);
|
||||
gamepad.sendGamepadReport();
|
||||
delay(200);
|
||||
|
||||
gamepad.release(1);
|
||||
gamepad.sendGamepadReport();
|
||||
delay(1800);
|
||||
} else {
|
||||
Serial.println("[BLE] En attente connexion...");
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user