BLE_API wrapper library for STMicroelectronics' BlueNRG Bluetooth Low Energy expansion board shield (Component)

Dependents:   Nucleo_Zumo_BLE_IDB04A1 contest_IOT5 contest_IOT6 contest_IOT_10 ... more

Fork of X_NUCLEO_IDB0XA1 by ST Expansion SW Team

Arduino Connector Compatibility Warning

X-NUCLEO-IDB04A1 and X-NUCLEO-IDB05A1 are Arduino compatible with an exception: instead of using pin D13 for the SPI clock, they use pin D3. The default configuration for this library is having the SPI clock on pin D3.

To be fully Arduino compatible, X-NUCLEO-IDB04A1 and X-NUCLEO-IDB05A1 need a small HW patch.

For X-NUCLEO-IDB04A1 this patch consists in removing zero resistor R10 and instead soldering zero resistor R11. For X-NUCLEO-IDB05A1 this patch consists in removing zero resistor R4 and instead soldering zero resistor R6.

In case you patch your board, then you also have to configure this library to use pin D13 to drive the SPI clock (see macro IDB0XA1_D13_PATCH in file x_nucleo_idb0xa1_targets.h).

If you use pin D13 for the SPI clock, please be aware that on STM32 Nucleo boards you may not drive the LED, otherwise you will get a conflict: the LED on STM32 Nucleo boards is connected to pin D13.

Referring to the current list of tested platforms (see X-NUCLEO-IDB04A1 and X-NUCLEO-IDB05A1 pages), the patch is required by ST-Nucleo-F103RB; ST-Nucleo-F302R8; ST-Nucleo-F411RE; and ST-Nucleo-F446RE.

Revision:
220:e02936f0d4c7
Parent:
217:23870c55b07e
Child:
222:37a7e289ee3d
--- a/source/BlueNRGGap.cpp	Thu Mar 31 11:16:47 2016 +0200
+++ b/source/BlueNRGGap.cpp	Tue Apr 05 11:23:33 2016 +0200
@@ -372,7 +372,7 @@
 
     /* Make sure we support the advertising type */
     if (params.getAdvertisingType() == GapAdvertisingParams::ADV_CONNECTABLE_DIRECTED) {
-        /* ToDo: This requires a propery security implementation, etc. */
+        /* ToDo: This requires a proper security implementation, etc. */
         return BLE_ERROR_NOT_IMPLEMENTED;
     }
 
@@ -415,44 +415,25 @@
         }
     }
 
-    /*aci_gap_set_discoverable(Advertising_Event_Type, Adv_min_intvl, Adv_Max_Intvl, Addr_Type, Adv_Filter_Policy,
-                        Local_Name_Length, local_name, service_uuid_length, service_uuid_list, Slave_conn_intvl_min, Slave_conn_intvl_max);*/
-    /*LINK_LAYER.H DESCRIBES THE ADVERTISING TYPES*/ 
+    advtInterval = params.getIntervalInADVUnits();
+    PRINTF("advtInterval=%ld\n\r", advtInterval);
 
-    // Enable the else branch if you want to set default device name
-    char* name = NULL;
-    uint8_t nameLen = 0; 
-    if(local_name!=NULL) {
-        name = (char*)local_name;
-        PRINTF("name=%s\n\r", name); 
-        nameLen = local_name_length;
-    } /*else {
-        char str[] = "ST_BLE_DEV";
-        name = new char[strlen(str)+1];
-        name[0] = AD_TYPE_COMPLETE_LOCAL_NAME;
-        strcpy(name+1, str);
-        nameLen = strlen(name);
-        PRINTF("nameLen=%d\n\r", nameLen);
-        PRINTF("name=%s\n\r", name);      
-    }*/
-
-    advtInterval = params.getIntervalInADVUnits(); // set advtInterval in case it is not already set by user application  
-    ret = aci_gap_set_discoverable(params.getAdvertisingType(), // Advertising_Event_Type                                
-        advtInterval,   // Adv_Interval_Min
-        advtInterval,   // Adv_Interval_Max
-        PUBLIC_ADDR, // Address_Type 
-        NO_WHITE_LIST_USE,  // Adv_Filter_Policy
-        nameLen, //local_name_length, // Local_Name_Length
-        (const char*)name, //local_name, // Local_Name
-        servUuidlength,  //Service_Uuid_Length
-        servUuidData, //Service_Uuid_List
-        0, // Slave_Conn_Interval_Min
-        0);  // Slave_Conn_Interval_Max
+    ret = aci_gap_set_discoverable(params.getAdvertisingType(), // AdvType
+                                   advtInterval,                // AdvIntervMin
+                                   advtInterval,                // AdvIntervMax
+                                   PUBLIC_ADDR,                 // OwnAddrType
+                                   NO_WHITE_LIST_USE,           // AdvFilterPolicy
+                                   local_name_length,           // LocalNameLen
+                                   (const char*)local_name,     // LocalName
+                                   servUuidlength,              // ServiceUUIDLen
+                                   servUuidData,                // ServiceUUIDList
+                                   0,                           // SlaveConnIntervMin
+                                   0);                          // SlaveConnIntervMax
 
     
-    PRINTF("!!!setting discoverable (servUuidlength=0x%x)\n", servUuidlength);
+    PRINTF("!!!setting discoverable (servUuidlength=0x%x)\n\r", servUuidlength);
     if(BLE_STATUS_SUCCESS!=ret) {
-       PRINTF("error occurred while setting discoverable (ret=0x%x)\n", ret);
+       PRINTF("error occurred while setting discoverable (ret=0x%x)\n\r", ret);
        switch (ret) {
          case BLE_STATUS_INVALID_PARAMS:
            return BLE_ERROR_INVALID_PARAM;
@@ -469,7 +450,7 @@
 
     // Before updating the ADV data, delete COMPLETE_LOCAL_NAME and TX_POWER_LEVEL fields (if present)
     if(AdvLen>0) {
-      if(name!=NULL) {
+      if(local_name!=NULL) {
         PRINTF("!!!calling aci_gap_delete_ad_type AD_TYPE_COMPLETE_LOCAL_NAME!!!\n");
         ret = aci_gap_delete_ad_type(AD_TYPE_COMPLETE_LOCAL_NAME);
         if (BLE_STATUS_SUCCESS!=ret){
@@ -1266,13 +1247,13 @@
     Scan_Interval, Scan_Window, Peer_Address_Type, Peer_Address, Own_Address_Type, Conn_Interval_Min, 
     Conn_Interval_Max, Conn_Latency, Supervision_Timeout, Conn_Len_Min, Conn_Len_Max    
   */
-  ret = aci_gap_create_connection(SCAN_P,
-				  SCAN_L,
+  ret = aci_gap_create_connection(_scanningParams.getInterval(),
+				  _scanningParams.getWindow(),
 				  PUBLIC_ADDR,
 				  (unsigned char*)_peerAddr,
 				  PUBLIC_ADDR,
 				  CONN_P1, CONN_P2, 0,
-				  SUPERV_TIMEOUT, CONN_L1 , CONN_L2);
+				  SUPERV_TIMEOUT, CONN_L1 , CONN_L1);
 
   _connecting = false;