Arduino-CommandParser icon indicating copy to clipboard operation
Arduino-CommandParser copied to clipboard

ESP32 SerialBT Error at Int: invalid int64_t for arg1

Open SphaeroX opened this issue 4 years ago • 0 comments

Unfortunately I can not parse numbers with the code on the Lolin32 via Bluetooth

Command: TEST 123

#include <CommandParser.h>
#include "BluetoothSerial.h"

typedef CommandParser<> MyCommandParser;

MyCommandParser parser;

BluetoothSerial SerialBT;

void cmd_test(MyCommandParser::Argument *args, char *response) {
  SerialBT.print("int64: "); SerialBT.println(args[0].asInt64);
  strlcpy(response, "success", MyCommandParser::MAX_RESPONSE_SIZE);
}

void setup() {
  SerialBT.begin("test");
  while (!Serial);

  parser.registerCommand("TEST", "i", &cmd_test);

}

void loop() {
  if (SerialBT.available()) {
    char line[128];
    size_t lineLength = SerialBT.readBytesUntil('\n', line, 127);
    line[lineLength] = '\0';

    char response[MyCommandParser::MAX_RESPONSE_SIZE];
    parser.processCommand(line, response);
    SerialBT.println(response);
  }
}

SphaeroX avatar Sep 04 '21 10:09 SphaeroX