Skip to content

Commit f710136

Browse files
authored
Merge pull request #7 from NoahRosa/master
Compatibility changes and bugfix
2 parents 5749fa1 + 404d6ac commit f710136

File tree

2 files changed

+10
-56
lines changed

2 files changed

+10
-56
lines changed

examples/Flight1/Flight1.ino

+9-55
Original file line numberDiff line numberDiff line change
@@ -91,32 +91,6 @@
9191
#define AD_TYPE_COMPLETE_LOCAL_NAME (0x09)
9292

9393

94-
95-
#ifdef ARDUINO_NUCLEO_F401RE
96-
#define STM32_UUID ((uint32_t *)0x1FFF7A10)
97-
#endif
98-
99-
#ifdef ARDUINO_NUCLEO_L476RG
100-
#define STM32_UUID ((uint32_t *)0x1FFF7590)
101-
#endif
102-
103-
#ifdef ARDUINO_NUCLEO_L053R8
104-
#define STM32_UUID ((uint32_t *)0x1FF8007C)
105-
#endif
106-
107-
#ifdef ARDUINO_NUCLEO_L152RE
108-
#define STM32_UUID ((uint32_t *)0x1FF80050)
109-
#endif
110-
111-
112-
/* BlueNRG Board Type */
113-
#define IDB04A1 0
114-
#define IDB05A1 1
115-
116-
/* Mems Board Type */
117-
#define IKS01A1 0
118-
#define IKS01A2 1
119-
12094
/*SPI Configuration*/
12195
#define IDB0XA1_PIN_SPI_MOSI (11)
12296
#define IDB0XA1_PIN_SPI_MISO (12)
@@ -189,34 +163,21 @@ class Flight1Service
189163
BlueNRG_RST();
190164
/* get the BlueNRG HW and FW versions */
191165
getBlueNRGVersion(&hwVersion, &fwVersion);
192-
if (hwVersion > 0x30) {
193-
/* X-NUCLEO-IDB05A1 expansion board is used */
194-
bnrg_expansion_board = IDB05A1;
195-
} else {
196-
/* X-NUCLEO-IDB0041 expansion board is used */
197-
bnrg_expansion_board = IDB04A1;
198-
}
166+
199167
BlueNRG_RST();
200168

201169
/*Generate MAC Address*/
202-
bdaddr[0] = (STM32_UUID[1]>>24)&0xFF;
203-
bdaddr[1] = (STM32_UUID[0] )&0xFF;
204-
bdaddr[2] = (STM32_UUID[2] >>8)&0xFF;
205-
bdaddr[3] = (STM32_UUID[0]>>16)&0xFF;
206-
bdaddr[4] = (hwVersion > 0x30) ?
207-
((((FLIGHT1_VERSION_MAJOR-48)*10) + (FLIGHT1_VERSION_MINOR-48)+100)&0xFF) :
208-
((((FLIGHT1_VERSION_MAJOR-48)*10) + (FLIGHT1_VERSION_MINOR-48) )&0xFF) ;
209-
bdaddr[5] = 0xC0; /* for a Legal BLE Random MAC */
170+
uint8_t data_len_out;
171+
ret = aci_hal_read_config_data(CONFIG_DATA_RANDOM_ADDRESS, 6, &data_len_out, bdaddr);
172+
210173
ret = aci_gatt_init();
211174
if(ret){
212175
FLIGHT1_PRINTF("\r\nGATT_Init failed\r\n");
213176
goto fail;
214177
}
215-
if (bnrg_expansion_board == IDB05A1) {
216-
ret = aci_gap_init_IDB05A1(GAP_PERIPHERAL_ROLE_IDB05A1, 0, 0x07, &service_handle, &dev_name_char_handle, &appearance_char_handle);
217-
}else {
218-
ret = aci_gap_init_IDB04A1(GAP_PERIPHERAL_ROLE_IDB04A1, &service_handle, &dev_name_char_handle, &appearance_char_handle);
219-
}
178+
179+
ret = aci_gap_init_IDB05A1(GAP_PERIPHERAL_ROLE_IDB05A1, 0, 0x07, &service_handle, &dev_name_char_handle, &appearance_char_handle);
180+
220181
if(ret != BLE_STATUS_SUCCESS){
221182
FLIGHT1_PRINTF("\r\nGAP_Init failed\r\n");
222183
goto fail;
@@ -254,7 +215,7 @@ class Flight1Service
254215
hwVersion,
255216
fwVersion>>8,
256217
(fwVersion>>4)&0xF,
257-
(hwVersion > 0x30) ? ('a'+(fwVersion&0xF)-1) : 'a',
218+
('a'+(fwVersion&0xF)-1),
258219
BoardName,
259220
bdaddr[5],bdaddr[4],bdaddr[3],bdaddr[2],bdaddr[1],bdaddr[0]);
260221

@@ -503,7 +464,7 @@ class Flight1Service
503464
return BLE_STATUS_SUCCESS;
504465

505466
fail:
506-
//FLIGHT1_PRINTF("Error while adding HW's Characteristcs service.\n");
467+
FLIGHT1_PRINTF("Error while adding HW's Characteristcs service.\n");
507468
return BLE_STATUS_ERROR;
508469
}
509470

@@ -512,7 +473,6 @@ class Flight1Service
512473

513474

514475
/*Private variables*/
515-
uint8_t bnrg_expansion_board;
516476
uint8_t bdaddr[6];
517477
uint16_t service_handle, dev_name_char_handle, appearance_char_handle;
518478
uint32_t PinForParing;
@@ -617,12 +577,6 @@ LSM303AGR_MAG_Sensor *Mag;
617577
void SetupSingleShot(VL53L1_X_NUCLEO_53L1A1 *sensor){
618578
int status;
619579

620-
//First set high timing value in order to change distance mode
621-
status = sensor->VL53L1X_SetTimingBudgetInMs(100);
622-
if( status ){
623-
SerialPort.println("SetMeasurementTimingBudgetMicroSeconds 1 failed");
624-
}
625-
626580
//Change distance mode to short range
627581
status = sensor->VL53L1X_SetDistanceMode(1);
628582
if( status ){

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=STM32duino FP_Examples
2-
version=1.1.1
2+
version=1.1.2
33
author=STMicroelectronics
44
maintainer=stm32duino
55
sentence=Provides several Function Packs that combine the usage of several X-NUCLEO boards

0 commit comments

Comments
 (0)