hello!
I am currently using the RN52s as an Arduino tool.
I made a board using the RN52s chip.
Using the RN52s chip, we were able to successfully operate the mouse cursor and bleuart functions simultaneously on a mobile phone.
First of all, let me tell you about the features of my board.
There are six buttons, and each button functions as a mouse cursor and scroll function on the phone.
Here, when I press key a, the mouse cursor moves to coordinates 500,800 on my phone. When I receive a command through bleuart, I want to make the mouse cursor move to a different coordinate when I press key a.
However, my code does not recognize the current command even though it is received.
Do you know the reason or a solution?
The board used in the Arduino tool is Adafruit Feather nRF52932.
Let me share my code.
void loop() {
static bool receivedA = false; // Flag to track if 'A' was received
// Check if BLEUART has data available
if (bleuart.available()) {
char receivedChar = (char)bleuart.read();
Serial.println(receivedChar);
if (receivedChar == 'A') {
receivedA = true; // Set flag if 'A' is received
} else {
receivedA = false; // Reset flag if any other character is received
}
}
// Check if 'A' was received or not
if (receivedA) {
taskBLE(); // Call taskBLE when 'A' is received
} else {
taskBLE_MOUSE(); // Call taskBLE_MOUSE when no 'A' received
}
// Forward data from HW Serial to BLEUART
while (Serial.available()) {
delay(2); // Delay to wait for enough input, since we have a limited transmission buffer
uint8_t buf[64];
int count = Serial.readBytes(buf, sizeof(buf));
bleuart.write(buf, count);
}
}