B4R Question Native C: How to use Strings/Chars?

Discussion in 'B4R Questions' started by KMatle, Mar 17, 2019 at 4:19 PM.

Tags:

Similar threads

B4R Tutorial Inline C / C++
B4R Tutorial HC 05 Classic Bluetooth
B4R Tutorial Additional Hardware Serial Ports
B4R Tutorial Connecting two ESP8266 boards
B4R Tutorial Strings and Bytes
  1. KMatle

    KMatle Expert Licensed User

    I'm working on how to use AES with an ESP32. Everything is fine except how to use/return strings (byte arrays/chars). There are some threads but I don't get it.

    Code:

    Code:
    Private enc() As Byte ' In Globals

    RunNative(
    "InitAES",Null' Call
    Inline C

    Code:
    #if C
    #include <mbedtls/aes.h>

    char rstr[50];

    void InitAES (B4R::Object* o) {
    b4r_main::_enc = rstr;


    }
    #End if
    Error:
    Code:
    b4r_main.cpp:61: error: cannot convert 'char [50]' to 'B4R::Array*' in assignment
    I simply need to return "rstr" to "enc"
     
  2. thetahsk

    thetahsk Member Licensed User

    Try this

    Code:
    b4r_main::_enc->data = rstr;
    b4r_main::_enc->length = strlen(rstr);
     
    Last edited: Mar 17, 2019 at 7:30 PM
    KMatle likes this.
  3. KMatle

    KMatle Expert Licensed User

    Thanks. That worked.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice