Bluetooth connection to PC
응답
16. 7. 8 오전 11:14

I am trying to connect the XDK to a UBT21-0 dongle. The XDK have the role of a server and should be a peripheral device. The program on the XDK is the same code as explained in the XDK  Bluetooth documentation or really similar to the example program "SendAcceleormeterDataOverBLe".

The dongle is the client and the central device which initializes the connection when it detects the device.

When I start a inquiry from the dongle I can detect the XDK but can't establish a connection. Unfortnuatly the the XDK give no feedback over printf that a pairing process/event has started or the device is invalid. I added printf in the bleCoreCallbck function for the event BLEEVENT_PAIRING_REQUEST in the BLE_stateHandler.

So far my relevant programm code:

static void bleAppServiceRegister(void) {
    serviceRegistryStatus =   BLEALPWDATAEXCHANGE_SERVER_Register(bleAlpwDataExchangeService);
}


void notificationCallback(BLE_connectionDetails_t connectionDetails)
{
    switch (connectionDetails.connectionStatus){
    case BLE_CONNECTED_TO_DEVICE:
    printf("Device connected: %02x:%02x:%02x:%02x:%02x:%02x \r\n",
    connectionDetails.remoteAddress.addr[0], .....);
    break;
    case BLE_DISCONNECTED_FROM_DEVICE:
    printf("Device disconnected!\r\n");
    break;
    default:
    printf("Invalid BLE Device");
    break;
    }
}
void bleAppHandler()
{
    BLE_notification_t configParams;
    BLE_returnStatus_t bleRetStatus;
    // callback function to react accordingly to the connection events
    configParams.callback = notificationCallback;
    // configuration to enable connection event notifications
    configParams.enableNotification = BLE_ENABLE_NOTIFICATION;
    // set configuration parameters to BLE stack
    bleRetStatus = BLE_enablenotificationForConnect(configParams);

    BLE_status bleStatus;
    // Registering the BLE Services
    bleStatus = BLE_customServiceRegistry(bleAppServiceRegister);
    }
    appInitReturn = BLE_coreStackInit();

    for (;;){
        // Notify that BLE data is received from base band
        bleTrsprtRetVal = BLE_hciReceiveData();
        // Run BLE state machine with specified configuration
        bleStateHandleRetVal = BLE_coreStateMachine();
        // Send data to the client if notification/indication enabled
        bleDataTransmit();

    }
}


void appInitSystem(xTimerHandle xTimer)
{
    (void) (xTimer);
    if (pdPASS!= xTaskCreate(bleAppHandler,    (const char * const) "BLE",    taskStackDepth, NULL, taskPriority,0))

}

At the momemt I am at a loss. I would like to know  if ever someone established a connection via Bluetooth to a PC? Any hints what I may have missed?

0 (0 투표)
RE: Bluetooth connection to PC
응답
16. 7. 11 오전 6:20 as a reply to Nils Pudleiner.

Hello Nils,

in order to help you I need further information about your project. Which use cases are you targeting? Do you want to write an app acting in the client role or just check if BLE is working on the XDK? Which OS/application are you using on your client device with the ble stick ? Which kind of pairing causes the issue in the client application ? Have you the option to print error messages in the client application when the pairing is failing ?

My first guess without the resquested informations would point to an issue with the pairing process.

Kind regards,
Manuel

0 (0 투표)
RE: Bluetooth connection to PC
응답
16. 7. 11 오전 10:36 as a reply to Manuel Cerny.

Hello Manuel,

Which use cases are you targeting?  Do you want to write an app acting in the client role or just check if BLE is working on the XDK?  

The goal is to configure the xdk as server which accept all connection request. After the connection is established the xdk send the Magneto-meter sensor data periodically to the pc/client (Windows). The sensor data should be integrated in Labview. The client is so configurated that it is connect to the xdk always when it finds it.

Which OS/application are you using on your client device with the ble stick ?

The nice thing about the UBT21-0 Bluetooth dogle is that entire protocol processing and storage of the configuration take place in the stick. This give the advantage that I once configurate the usb stick with AT commamnds to connect to specified device and then only have to read a serial port to get the data. Thereby it should be independent of the OS on the PC.

Have you the option to print error messages in the client application when the pairing is failing ?

After the BLE inquiry I try to connect to the XDK but I just receive after some seconds an "ERROR" in the console that the BLE bonding failed. The stick is configurate to connect when it finds the device. The security setting is "just works"  (BT 2.0 - Enable, BT 2.1 - Auto Accept), (no passkey, fixed pin or other things). Unfortunatly I can't get a more preceise message of the client, why the connection failed. Thus it would be very nice to get feedback from the xdk if a pairing process has started but over printf I get no infomoration.

When I change the Security settings to "Display Only" (BT. 2.0 Enable,BT 2.1 Display Passkey) I can establish a connection to my mobile phone. Both device exchange the Passkey and building up the connection.

There excist the possiblity to write a own program on the stick(client) but therefore it is necessary to buy a Development kit.

The bluetooth address of the xdk changes sometimes. How I can stop that?

0 (0 투표)
RE: Bluetooth connection to PC
응답
16. 7. 13 오전 6:04 as a reply to Nils Pudleiner.

Hi Nils,

to disable random addressing in the XDK you can go to "BLECustomConfig.h" under /SDK/xdk110/Common/config/ and change in the file:
 

define BLE_RANDOM_ADDRESSING_SUPPORT 1

to   

#define BLE_RANDOM_ADDRESSING_SUPPORT 0


This should change the default behaviour of the XDK to use a random address for every advertisement, scanning and connection. This can be considered to be a security feature in order to not use the static address and leave traces after interacting with other BT devices. 
So if you change this setting parameter to static addresses your XDK should use the static and public address of it's own network interface. 

For the problems with the connection establishment I would guess that there is an issue happening during the pairing / bonding process so that your standard BLE device does not allow / enable further communication with the XDK. We will look into this exact use case and try to reproduce it and even go into detailled debugging and logging of information. Therefore we should be able to get a better understanding until Monday next week.

Could you in the meantime check with any other BLE enabled devices and the matching apps if you are able to connect to your XDK at all and it is not broken (e.g. CZBLEControl App for iOS).

- Manuel

0 (0 투표)
RE: Bluetooth connection to PC
응답
16. 7. 19 오전 4:36 as a reply to Manuel Cerny.

I got one good news. I can connect the xdk to my mobile phone and a pairing Event is triggered by the xdk. This is a hint that something is still wrong with the configuration of the dongle.

The bad news is that I can't switch off the BLE_Random Address. If I am doing it, I will receive 20 errors. I am going to call the producer of the bluetooth dongle to get info how to activate the random address in the dongle.

0 (0 투표)
RE: Bluetooth connection to PC
응답
16. 7. 20 오전 9:03 as a reply to Nils Pudleiner.

Hi Nils,

great to hear that you can establish a connection to your mobile phone.
So the next step would be to analyse, what the dongle is doing different than your phone.

Please keep me posted, it you are making progress.

Kind regards,
Manuel

0 (0 투표)