Skip to content

Commit 21aaa56

Browse files
committed
Fix ARMCC link issues on platform who doesn't provide implementation of
mbed BLE. ARMCC generate error at link time if the symbol `createBLEInstance` is not here, even if it is not used. This patch provide a weak version of `createBLEInstance` who just assert if called. It also allows programs which use mbed BLE to be compiled on platforms without mbed BLE implementation, then a runtime error will be generated.
1 parent b61583f commit 21aaa56

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

bluetooth/ble/source/BLE.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
#include <minar/minar.h>
2626
#endif
2727

28+
#if !defined(YOTTA_CFG_MBED_OS)
29+
#include <mbed_error.h>
30+
#include <toolchain.h>
31+
#endif
32+
2833
ble_error_t
2934
BLE::initImplementation(FunctionPointerWithContext<InitializationCompleteCallbackContext*> callback)
3035
{
@@ -82,6 +87,20 @@ BLE::initImplementation(FunctionPointerWithContext<InitializationCompleteCallbac
8287
* This may be overridden.
8388
*/
8489
#define INITIALIZER_LIST_FOR_INSTANCE_CONSTRUCTORS createBLEInstance
90+
91+
// yotta unlike mbed-cli has proper dependency mechanisms
92+
// It is not required to defined a stub for createBLEInstance
93+
#if !defined(YOTTA_CFG_MBED_OS)
94+
95+
// this stub is required by ARMCC otherwise link will systematically fail
96+
MBED_WEAK BLEInstanceBase* createBLEInstance() {
97+
error("Please provide an implementation for mbed BLE");
98+
return NULL;
99+
}
100+
101+
#endif
102+
103+
85104
#endif /* YOTTA_CFG_BLE_INSTANCES_COUNT */
86105

87106
typedef BLEInstanceBase *(*InstanceConstructor_t)(void);

0 commit comments

Comments
 (0)