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:
225:31b976a40f43
diff -r b94d080127c7 -r f2a7da5d24e1 source/platform/btle.cpp
--- a/source/platform/btle.cpp	Thu Jun 16 12:08:19 2016 +0000
+++ b/source/platform/btle.cpp	Fri Jun 17 16:07:05 2016 +0000
@@ -88,17 +88,69 @@
 
 /**************************************************************************/
 /*!
-    @brief  Initialises BTLE and the underlying HW/Device
-    @param  isSetAddress boolean if address has been set
-    @param  mosi MOSI Pin
-    @param  miso MISO Pin
-    @param  sclk clock Pin
+    @brief  Prepare communication between the host and the BTLE HW device
     @returns void
 */
 /**************************************************************************/
-void btleInit(bool isSetAddress, uint8_t role)
+void btleInitHW(void)
+{
+    PRINTF("btleInitHW>>\n\r");
+
+    /* Delay needed only to be able to acces the JTAG interface after reset
+    if it will be disabled later. */
+    //Clock_Wait(500); FIXME: // check if I can remove this
+
+    /* Initialize the BlueNRG HCI */
+    HCI_Init();
+}
+
+/**************************************************************************/
+/*!
+  * @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 btleUpdateFirmware(const uint8_t *fw_image, uint32_t fw_size)
 {
-    PRINTF("btleInit>>\n\r");
+	int status = program_device(fw_image, fw_size);
+	
+	return (status);
+}
+
+/**************************************************************************/
+/*!
+  * @brief  Get BlueNRG HW updater version
+  * @param  version This parameter returns the updater HW version.
+  * @retval Status of the call
+  */
+/**************************************************************************/
+uint8_t btleGetUpdaterHWVersion(uint8_t *upd_hw_version)
+{
+	uint8_t status;
+	
+	status = getBlueNRGUpdaterHWVersion(upd_hw_version);
+
+	return (status);
+}
+
+
+/**************************************************************************/
+/*!
+    @brief  Start the BTLE stack with the specified role
+    @param  isSetAddress boolean if address has been set
+    @param  role The device role
+    @returns void
+*/
+/**************************************************************************/
+void btleStart(bool isSetAddress, uint8_t role)
+{
     /* Avoid compiler warnings about unused variables. */
     (void)isSetAddress;
     
@@ -107,13 +159,6 @@
     uint16_t fwVersion;
     uint16_t service_handle, dev_name_char_handle, appearance_char_handle;
 
-    /* Delay needed only to be able to acces the JTAG interface after reset
-    if it will be disabled later. */
-    Clock_Wait(500);
-
-    /* Initialize the BlueNRG HCI */
-    HCI_Init();
-
     /* Reset BlueNRG SPI interface */
     BlueNRG_RST();