Translating commands from java to cpp/arduino

hi fellows,

i am trying to convert some hex commands
out of a java project onto the arduino.
should be easy i thought but its not working :frowning:
in this project are
the commands written. I would like to translate the “takeoff” command.

JAVA:

 writeTakeoff() {
        const buffer = this.createBuffer(COMMAND_KEY, [MD_CLASSES.PILOTING, MD_METHODS.TAKEOFF, 0x00]);
        this.write(COMMAND_KEY, buffer);
        Logger.info('Takeoff command called');
    }
[b]const COMMAND_KEY = 'fa0b';[/b]

const MD_CLASSES = {
    PILOTING: 0x00,
    SPEED_SETTINGS: 0x01,
    ANIMATION: 0x04,
    MEDIA_RECORD: 0x06,
    PILOTING_SETTINGS: 0x08,
    NAVIGATION_DATA_STATE: 0x18,
};

const MD_METHODS = {
    TRIM: 0x00,
    TAKEOFF: 0x01,
    LAND: 0x03,
    EMERGENCY: 0x04,
    PICTURE: 0x01,
    FLIP: 0x00,
    MAX_ALTITUDE: 0x00,
    MAX_TILT: 0x01,
    MAX_VERTICAL_SPEED: 0x00,
    MAX_ROTATION_SPEED: 0x01,
    DRONE_POSITION: 0x00,
};

so getting this right i would have to send this:
0xfa, 0x0b, 0xfa, 0x0b, 0x02, 0x00, 0x01, 0x00

now using my code it works to send it but the drone wich receives the command is not
doing anything, and i am lost right now. is maybe the formatting wrong or anything?

this is my whole code for notice:

#include <SoftwareSerial.h>

int btRXD = 8;
int btTXD = 7;

int ledB = 3;
int ledG = 2;

int buttonB = 12;
int buttonY = 11;

int byteLeng;

int steps = 0;

SoftwareSerial BTSerial(btTXD, btRXD);

//START BEREICH TESTVARIABELN

//'fa00', 'fa0b', [4, ++steps.fa0b, 2, 0, 1, 0]
// HANDSHAKE "fb0f", "fb0e", "fb1b", "fb1c", "fd22", "fd23", "fd24", "fd52", "fd53", "fd54"                                   //FROM guthub https://github.com/voodootikigod/node-rolling-spider/blob/master/lib/drone.js
// HANDSHAKE 'fa00', 'fa0b', [4, ++steps.fa0b, 0, 4, 1, 0, 0x32, 0x30, 0x31, 0x34, 0x2D, 0x31, 0x30, 0x2D, 0x32, 0x38, 0x00   //FROM github poshaughnessy https://github.com/poshaughnessy/web-bluetooth-parrot-drone/blob/master/js/drone.js
//CHARACTERISTIC MAP 'fb0f', 'fb0e', 'fb1b', 'fb1c', 'fd22', 'fd23', 'fd24', 'fd52', 'fd53', 'fd54'         smame as handshake//FROM github Fetherston https://github.com/fetherston/npm-parrot-minidrone/blob/master/lib/MiniDroneBtAdapter.js
//byte handshakeByte[] = {0xfb, 0x0f, 0xfb, 0x0e, 0xfb, 0x1b, 0xfb, 0x1c, 0xfd, 0x22, 0xfd, 0x23, 0xfd, 0x24, 0xfd, 0x52, 0xfd, 0x53, 0xfd, 0x54}; //FROM voodotikigod




byte takeoffByte[] = {0xfa, 0x0b, 0xfa, 0x0b, 0x02, 0x00, 0x01, 0x00};





void setup() {

  Serial.begin(9600);
  pinMode(ledB, OUTPUT);
  pinMode(ledG, OUTPUT);
  pinMode(buttonB, INPUT_PULLUP);
  pinMode(buttonY, INPUT_PULLUP);

  BTSerial.begin(9600);
  BTSerial.write("AT+DEFAULT");
  BTSerial.write("AT+RESET");
  BTSerial.write("AT+ROLE1"); //Master Role
  BTSerial.write("AT+TYPE0"); //Simple pairing
  BTSerial.write("AT+IMME1");
  BTSerial.write("AT+SHOW1");
  BTSerial.write("AT+START");
  BTSerial.write("AT+NAME:willyLFmaja");

  Serial.write("Setup completed!\n");

  digitalWrite(ledG, HIGH);
  delay(500);
  digitalWrite(ledG, LOW);
}

void loop()
{
  listenAll();

  //SendingCommands
  if (digitalRead(buttonB) == LOW)
  {
    digitalWrite(ledG, HIGH);
    Serial.write("\nTAKEOFF!\n");

    byteLeng = sizeof(handshakeByte);
    comBT(handshakeByte, byteLeng);
    delay(400);
    listenAll();
    delay(400);
    listenAll();
    byteLeng = sizeof(takeoffByte);
    comBT(takeoffByte, byteLeng);


    digitalWrite(ledB, HIGH);
    Serial.write("\n");
    delay(400);
    digitalWrite(ledB, LOW);

    listenAll();

    Serial.write("\n");
    digitalWrite(ledG, LOW);
  }

  //SCAN WHAT IS AROUND
  if (digitalRead(buttonY) == LOW)
  {
    digitalWrite(ledB, HIGH);
    Serial.write("\nSearching (7sec):");
    BTSerial.write("AT+DISC?");
    listenAll();
    delay(10000);
    listenAll();
    do {
      Serial.write(BTSerial.read());
    } while (BTSerial.available());
    listenAll();
    
    Serial.write("\n");
    digitalWrite(ledB, LOW);
  }
  //BTSerial.write("AT+CON:E014E5583DD1");
  listenAll();

}

//Functions


void comBT(byte commandline[], int commsize)
{ 
  byte temp[commsize];
  
  Serial.write("\nLenght:");
  Serial.print(commsize);
  
  for(int i=0; i < commsize; i++)
  {
    temp[i] = commandline[i];
    Serial.print(temp[i]);
  } 

  digitalWrite(ledB, HIGH);
  Serial.write("\nSending:");

  BTSerial.write((char*)temp, commsize);
  
  listenAll();
  delay(500);
  listenAll();
  digitalWrite(ledB, LOW);
}

void listenAll()
{
  do {
    if (BTSerial.available())
    {
      Serial.write(BTSerial.read());
    }
  } while (BTSerial.available());
  do {
    if (Serial.available())
    {
      BTSerial.write(Serial.read());
    }
  } while (Serial.available());
}

What does this.createBuffer() do with the first argument? Does it cram it into the buffer, and then you pass the same argument to this.write()? I would expect not.

COMMAND_KEY appears to be four ASCII characters, not four hex digits, so I think it's more likely you want:

const byte MD_CLASSES_PILOTING = 0x00;
const byte MD_METHODS_TAKEOFF = 0x01;
byte takeoffByte[] = {'f', 'a', '0', 'b', MD_CLASSES_PILOTING, MD_METHODS_TAKEOFF, 0x00};

Can you send to me an MP please ?? thanks u