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

Fork of X_NUCLEO_IDB0XA1 by ST Expansion SW Team

Revision:
232:f2a7da5d24e1
Parent:
231:b94d080127c7
diff -r b94d080127c7 -r f2a7da5d24e1 source/BlueNRGDevice.cpp
--- a/source/BlueNRGDevice.cpp	Thu Jun 16 12:08:19 2016 +0000
+++ b/source/BlueNRGDevice.cpp	Fri Jun 17 16:07:05 2016 +0000
@@ -108,6 +108,13 @@
     nCS_ = 1;
 
     wait_us(500);
+    
+	// Set the interrupt handler for the device
+	irq_.mode(PullDown); // set irq mode
+	irq_.rise(&HCI_Isr);    
+    
+    // Prepare communication between the host and the BTLE HW device
+    btleInitHW();
 }
 
 /**************************************************************************/
@@ -119,6 +126,37 @@
 {
 }
 
+/**
+  * @brief  Get BlueNRG HW updater version
+  * @param  version This parameter returns the updater HW version.
+  * @retval Status of the call
+  */
+uint8_t BlueNRGDevice::getUpdaterHardwareVersion(uint8_t *upd_hw_version)
+{
+	uint8_t status;
+	
+	status = btleGetUpdaterHWVersion(upd_hw_version);
+
+	return (status);
+}
+
+/**
+  * @brief  Flash a new firmware using internal bootloader.
+  * @param  fw_image     Pointer to the firmware image (raw binary data,
+  *                      little-endian).
+  * @param  fw_size      Size of the firmware image. The firmware image size shall
+  *                      be multiple of 4 bytes.
+  * @retval int      It returns 0 if successful, or a number not equal to 0 in
+  *                  case of error (ACI_ERROR, UNSUPPORTED_VERSION,
+  *                  WRONG_IMAGE_SIZE, CRC_ERROR)
+  */
+int BlueNRGDevice::updateFirmware(const uint8_t *fw_image, uint32_t fw_size)
+{
+	int status = btleUpdateFirmware(fw_image, fw_size);
+	
+	return (status);
+}
+
 
 /**
     @brief  Initialises anything required to start using BLE
@@ -135,14 +173,11 @@
         	callback.call(&context);
         	return BLE_ERROR_ALREADY_INITIALIZED;
     	}
-
-	// Set the interrupt handler for the device
-	irq_.mode(PullDown); // betzw: set irq mode
-	irq_.rise(&HCI_Isr);
 	
 	/* ToDo: Clear memory contents, reset the SD, etc. */
+	// Start the BlueNRG/BlueNRG-MS stack
 	// By default, we set the device GAP role to PERIPHERAL
-	btleInit(BlueNRGGap::getInstance().getIsSetAddress(), GAP_PERIPHERAL_ROLE_IDB04A1);
+	btleStart(BlueNRGGap::getInstance().getIsSetAddress(), GAP_PERIPHERAL_ROLE_IDB04A1);
 	
 	isInitialized = true;
 	BLE::InitializationCompleteCallbackContext context = {