Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of X_NUCLEO_IDB0XA1 by
Revision 234:3f6bba52b307, committed 2016-05-26
- Comitter:
- Andrea Palmieri
- Date:
- Thu May 26 15:34:04 2016 +0200
- Parent:
- 233:488e0e8b9b43
- Child:
- 235:31b976a40f43
- Commit message:
- Fix bug on intervals setting
Signed-off-by: Andrea Palmieri <andrea.palmieri@st.com>
Changed in this revision
| source/BlueNRGGap.cpp | Show annotated file Show diff for this revision Revisions of this file |
| x-nucleo-idb0xa1/BlueNRGGap.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/source/BlueNRGGap.cpp Mon May 23 18:32:06 2016 +0200
+++ b/source/BlueNRGGap.cpp Thu May 26 15:34:04 2016 +0200
@@ -1304,8 +1304,14 @@
scanInterval = _scanningParams.getInterval();
scanWindow = _scanningParams.getWindow();
}
- conn_min_interval = (_advParams.ADVERTISEMENT_DURATION_UNITS_TO_MS(advInterval)+GUARD_INT)/1.25;
- conn_max_interval = (_advParams.ADVERTISEMENT_DURATION_UNITS_TO_MS(advInterval)+GUARD_INT)/1.25;
+
+ if(advInterval>(MAX_INT_CONN-(GUARD_INT/1.25))) { //(4000-GUARD_INT)ms
+ conn_min_interval = MAX_INT_CONN;
+ conn_max_interval = MAX_INT_CONN;
+ } else {
+ conn_min_interval = (_advParams.ADVERTISEMENT_DURATION_UNITS_TO_MS(advInterval)+GUARD_INT)/1.25;
+ conn_max_interval = (_advParams.ADVERTISEMENT_DURATION_UNITS_TO_MS(advInterval)+GUARD_INT)/1.25;
+ }
} else {
@@ -1313,14 +1319,19 @@
scanInterval = _scanningParams.getInterval();
scanWindow = _scanningParams.getWindow();
- conn_min_interval = SCAN_DURATION_UNITS_TO_MSEC(scanInterval)/1.25;
- conn_max_interval = SCAN_DURATION_UNITS_TO_MSEC(scanInterval)/1.25;
-
+ if(SCAN_DURATION_UNITS_TO_MSEC(scanInterval)>(MAX_INT_CONN*1.25) ||
+ SCAN_DURATION_UNITS_TO_MSEC(scanInterval)<(MIN_INT_CONN*1.25)) { //(4000)ms || (7.5)ms
+ conn_min_interval = DEF_INT_CONN;
+ conn_max_interval = DEF_INT_CONN;
+ } else {
+ conn_min_interval = SCAN_DURATION_UNITS_TO_MSEC(scanInterval)/1.25;
+ conn_max_interval = SCAN_DURATION_UNITS_TO_MSEC(scanInterval)/1.25;
+ }
}
PRINTF("scanInterval=%u[msec]\r\n",SCAN_DURATION_UNITS_TO_MSEC(scanInterval));
PRINTF("scanWindow()=%u[msec]\r\n",SCAN_DURATION_UNITS_TO_MSEC(scanWindow));
- PRINTF("conn_min_interval[msec]=%u\r\n",(unsigned)(conn_min_interval*1.25));
- PRINTF("conn_max_interval[msec]=%u\r\n",(unsigned)(conn_max_interval*1.25));
+ PRINTF("conn_min_interval=%u[msec]\r\n",(unsigned)(conn_min_interval*1.25));
+ PRINTF("conn_max_interval=%u[msec]\r\n",(unsigned)(conn_max_interval*1.25));
}
--- a/x-nucleo-idb0xa1/BlueNRGGap.h Mon May 23 18:32:06 2016 +0200 +++ b/x-nucleo-idb0xa1/BlueNRGGap.h Thu May 26 15:34:04 2016 +0200 @@ -62,6 +62,9 @@ #define CONN_L1 (0x0008) #define CONN_L2 (0x0008) #define GUARD_INT 5 //msec +#define MIN_INT_CONN 0x0006 //=>7.5msec +#define MAX_INT_CONN 0x0C80 //=>4000msec +#define DEF_INT_CONN 0x0140 //=>400msec (default value for connection interval) #define LOCAL_NAME_MAX_SIZE 9 //8 + 1(AD_DATA_TYPE) #define UUID_BUFFER_SIZE 17 //Either 8*2(16-bit UUIDs) or 4*4(32-bit UUIDs) or 1*16(128-bit UUIDs) +1(AD_DATA_TYPE)
