B4R Question [inline c] get array by pointer

peacemaker

Expert
Licensed User
Longtime User
Hi, All

C-code:
  const uint8_t* point = esp_bt_dev_get_address();

  for (int i = 0; i < 6; i++) {
    char str[3];
    sprintf(str, "%02X", (int)point[i]);
    Serial.print(str);

    if (i < 5) {
      Serial.print(":");
    }
  }

How to get correctly the mac-address array to MacArray by this pointer got inside inline-c ? (it's not WiFi's mac-address that is got as array).

B4R:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public MacArray(6) As Byte
End Sub

Sub Get_btMacAddress() As Byte()
    RunNative("getBTMac", Null)
    Return MacArray
End Sub
#if C
#include "esp_bt_main.h"
#include "esp_bt_device.h"
  void getBTMac(B4R::Object* u) {
      const uint8_t* point = esp_bt_dev_get_address();
    //(Byte*)b4r_others::_macarray->data = point; ????
  }

#end if
 

peacemaker

Expert
Licensed User
Longtime User
Strange, it's not pointer, but SOLVED:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public MacArray(6) As Byte
End Sub

Sub Get_btMacAddress
    RunNative("getBTMac", Null)
End Sub
#if C
#include "esp_bt_main.h"
#include "esp_bt_device.h"
  void getBTMac(B4R::Object* u) {
      const uint8_t* point = esp_bt_dev_get_address();
    memcpy(b4r_others::_macarray->data, point, 6);
  }
#end if

 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…