Application to update the BlueNRG-MS firmware of X-NUCLEO-IDB05A1 component board
Dependencies: mbed X_NUCLEO_IDB0XA1 BLE_API
Fork of BlueNRG-MS-Stack-Updater by
BlueNRG-MS Stack Updater
This program allows to update BlueNRG-MS (X-NUCLEO-IDB05A1) stack image.
It programs BlueNRG-MS with the latest version of stack image provided through a C array: img73.c
The target firmware version is 7.3 (BLE 4.2 compliance). If the update is successful, LED1 blinks slowly; on error, LED1 blinks fast.
Tested platforms
Note
This application should not be used to update the stack image of BlueNRG (X-NUCLEO-IDB04A1) component which is considered deprecated.
Diff: main.cpp
- Revision:
- 0:872cf47093cf
- Child:
- 1:d4887d7f5e85
diff -r 000000000000 -r 872cf47093cf main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Jun 17 16:11:27 2016 +0000
@@ -0,0 +1,75 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2006-2015 ARM Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "mbed.h"
+#include "BlueNRGDevice.h"
+
+#define BLUENRG_MS_HW_VERSION (0x31)
+
+#include "img72a.c"
+
+DigitalOut led1(LED1);
+
+
+void error_loop(void)
+{
+ // Blink fast to signal error condition
+ while (1) {
+ led1 = !led1;
+ wait_ms(150);
+ }
+}
+
+
+int main(void)
+{
+ uint8_t hw_version;
+ uint8_t get_hw_version_status;
+ int update_status;
+ BlueNRGDevice* bleDevice;
+
+ // Keep LED1 turned on to show that update is in progress
+ led1 = 1;
+
+ bleDevice = (BlueNRGDevice*) createBLEInstance();
+ get_hw_version_status = bleDevice->getUpdaterHardwareVersion(&hw_version);
+
+ if (get_hw_version_status != BLE_STATUS_SUCCESS) {
+ printf("ERROR: Unable to get HW version\n\r");
+ error_loop();
+ }
+
+ if ( (hw_version < BLUENRG_MS_HW_VERSION) || (hw_version > BLUENRG_MS_HW_VERSION) ) {
+ printf("Sorry, you're HW version is not supported\n\r");
+ error_loop();
+ }
+
+ printf("Start updating BlueNRG-MS firmware...\n\r");
+
+ update_status = bleDevice->updateFirmware(fw_image, sizeof(fw_image));
+
+ if (update_status != BLE_STATUS_SUCCESS) {
+ printf("ERROR: Unable to update firmware\n\r");
+ error_loop();
+ }
+
+ printf("Firmware updated successfully!\n\r");
+ // Blink slowly to signal successful firmware update
+ while (1) {
+ led1 = !led1;
+ wait(1);
+ }
+}
