is it correct?
I'm wondering this because by printing Serial.print(et_prepareMessage()); the result I can not see the hex string but some strange character.
Thank you
Returning the address of a local variable declared on the stack is bound to cause problems, because the memory it occupied on the stack is quickly reused.
Move the declaration of buffer[] out of the function to make it global and it should help.
Serial.print() is good for printable characters, which is not your case. The second byte would be treated as a string terminating character so you would only send one byte. You should use Serial.write().
In your particular use case you may also do without a buffer, just call repeatedly Serial.write() with the different bytes. If you think you really need a buffer, either declare it globally or declare it within loop, then pass it as an argument to et_prepareMessage(). This way the buffer will not go out of scope when et_prepareMessage returns.
Not yet. In getCheckSum() you use strlen, which is based on the presence of a string terminating char (0). But your second byte is 0 so strlen will return 1 and the checksum will be wrong. You can hardcode the length directly in the for() loop, but if you want to make getCheckSum() reusable you can add a second argument for the length of the buffer, i.e. declare getCheckSum(byte* buf, int len).
The general rule is that for an array of bytes without a terminating char you need to supply its length. So, when you call Serial.write() you should pass the buffer length, i.e. Serial.write(buf, len).