BLE device initialization under OSX


#1

Hello,

I try to build with the current SDK a C program to catch my Mamboo and Airborn drone via bluetooth. So I start following the Beebop example. I’m try to initialize the BLE stack like:

ARNETWORKAL_BLEDeviceManager_t* l_blemanager = NULL;
ARNETWORKAL_BLEDevice_t* l_bledevice = NULL;

ARNETWORKAL_Manager_InitBLENetwork( l_network, l_blemanager, l_bledevice, 10, NULL, 0 );

I don’t find out how I can initialize the BLEDeviceManager and BLEDevice on OSX. I have found this thread SDK update include BLE support in C? but my question is, is there an example for OSX, because I don’t know how I can initialize both pointers. I don’t find an “Init” function.

Thanks


#2

Hi,

You might be interested by a contribution to the Samples done by Sean Weaver.

Regards,
Djavan


#3

Thanks this look very nice, so I will take look into it, but did you know other OS Linux or Windows examples?

Thanks


#4

I have tried to create a working discovery example based on the link (with Objectiv-C code) and the JNI parts within the SDK. My testing code shows:

#include <assert.h>
#include <stdio.h>

#include <libARNetworkAL/ARNetworkAL.h>
#include <libARDiscovery/ARDiscovery.h>

#define ROLLINGSPIDER_CONTROLLER_TO_DEVICE_NONACK_ID 10
#define ROLLINGSPIDER_CONTROLLER_TO_DEVICE_ACK_ID 11
#define ROLLINGSPIDER_CONTROLLER_TO_DEVICE_EMERGENCY_ID 12
#define ROLLINGSPIDER_DEVICE_TO_CONTROLLER_NAVDATA_ID ((ARNETWORKAL_MANAGER_BLE_ID_MAX /2) - 1)
#define ROLLINGSPIDER_DEVICE_TO_CONTROLLER_EVENT_ID ((ARNETWORKAL_MANAGER_BLE_ID_MAX /2) - 2)

typedef struct
{
    ARNETWORKAL_BLEDeviceManager_t deviceManager;
    ARNETWORKAL_BLEDevice_t device;
} ARDISCOVERY_DEVICE_BLE_t;

int main()
{
    eARDISCOVERY_ERROR l_error = ARDISCOVERY_OK;
    ARDISCOVERY_Device_t* l_device = ARDISCOVERY_Device_New( &l_error );
    assert( l_error == ARDISCOVERY_OK );

    if ( l_device->networkType == ARDISCOVERY_NETWORK_TYPE_BLE )
    {
        ARDISCOVERY_Device_Delete( &l_device );
        return -1;
    }

    eARNETWORKAL_ERROR l_errornetwork = ARNETWORKAL_OK;
    ARNETWORKAL_Manager_t* l_networkmanager = ARNETWORKAL_Manager_New( &l_errornetwork );
    assert( l_errornetwork == ARNETWORKAL_OK );

    int bleNotificationIDs[] = {
        ROLLINGSPIDER_DEVICE_TO_CONTROLLER_NAVDATA_ID,
        ROLLINGSPIDER_DEVICE_TO_CONTROLLER_EVENT_ID,
        (ROLLINGSPIDER_CONTROLLER_TO_DEVICE_ACK_ID + (ARNETWORKAL_MANAGER_BLE_ID_MAX / 2)),
        (ROLLINGSPIDER_CONTROLLER_TO_DEVICE_EMERGENCY_ID + (ARNETWORKAL_MANAGER_BLE_ID_MAX / 2)),
    };
    uint32_t numberOfNotificationID = sizeof(bleNotificationIDs) / sizeof(int);

    ARDISCOVERY_DEVICE_BLE_t* l_bleparameter = (ARDISCOVERY_DEVICE_BLE_t*) l_device->specificParameters;
    ARNETWORKAL_Manager_InitBLENetwork( l_networkmanager, l_bleparameter->deviceManager, l_bleparameter->device, 1, bleNotificationIDs, numberOfNotificationID );

    ARNETWORKAL_Manager_Delete( &l_networkmanager );
    ARDISCOVERY_Device_Delete( &l_device );
}

The call ARNETWORKAL_Manager_InitBLENetwork breaks with a segmentation faul, imho the second and third paramter are wrong. The l_device->specificParameters returns a void* but I need for the InitBLENetwork two parameters.
The devicemanager also the device are both the native pointer of the OS, but how I can get these native pointers?

Thanks


Python for minidrones (BLE)