diff --git a/ble/src/u_ble_extmod.c b/ble/src/u_ble_extmod.c index 3b96474a..0c8cab82 100644 --- a/ble/src/u_ble_extmod.c +++ b/ble/src/u_ble_extmod.c @@ -44,6 +44,11 @@ #include "u_ble.h" #include "u_ble_private.h" +// The headers below are necessary to work around an Espressif linker problem, see uBleInit() +#include "u_network.h" +#include "u_network_config_ble.h" +#include "u_network_private_ble.h" + /* ---------------------------------------------------------------- * COMPILE-TIME MACROS * -------------------------------------------------------------- */ @@ -67,6 +72,16 @@ // Initialise the ble driver. int32_t uBleInit(void) { + // Workaround for Espressif linker missing out files that + // only contain functions which also have weak alternatives + // (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899) + // Basically any file that might end up containing only functions + // that also have WEAK linked counterparts will be lost, so we need + // to add a dummy function in those files and call it from somewhere + // that will always be present in the build, which for BLE we + // choose to be here + uNetworkPrivateBleLink(); + uBleSpsPrivateInit(); return uShortRangeInit(); } diff --git a/cell/api/u_cell_http.h b/cell/api/u_cell_http.h index 6dd83a08..b11d7fd2 100644 --- a/cell/api/u_cell_http.h +++ b/cell/api/u_cell_http.h @@ -127,6 +127,18 @@ typedef void (uCellHttpCallback_t) (uDeviceHandle_t cellHandle, const char *pFileNameResponse, void *pCallbackParam); +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uCellHttpPrivateLink(void); + /* ---------------------------------------------------------------- * FUNCTIONS * -------------------------------------------------------------- */ diff --git a/cell/api/u_cell_loc.h b/cell/api/u_cell_loc.h index 641e942b..88596ce5 100644 --- a/cell/api/u_cell_loc.h +++ b/cell/api/u_cell_loc.h @@ -134,6 +134,18 @@ extern "C" { * TYPES * -------------------------------------------------------------- */ +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uCellLocPrivateLink(void); + /* ---------------------------------------------------------------- * FUNCTIONS: MISC * -------------------------------------------------------------- */ diff --git a/cell/api/u_cell_mqtt.h b/cell/api/u_cell_mqtt.h index 1ed004ef..6be5e83c 100644 --- a/cell/api/u_cell_mqtt.h +++ b/cell/api/u_cell_mqtt.h @@ -153,6 +153,17 @@ typedef struct { // *INDENT-ON* } uCellMqttSnTopicName_t; +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uCellMqttPrivateLink(void); /* ---------------------------------------------------------------- * FUNCTIONS: MQTT AND MQTT-SN diff --git a/cell/api/u_cell_sec.h b/cell/api/u_cell_sec.h index f9151dfc..f8208512 100644 --- a/cell/api/u_cell_sec.h +++ b/cell/api/u_cell_sec.h @@ -56,6 +56,18 @@ extern "C" { * TYPES * -------------------------------------------------------------- */ +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uCellSecPrivateLink(void); + /* ---------------------------------------------------------------- * FUNCTIONS: INFORMATION * -------------------------------------------------------------- */ diff --git a/cell/api/u_cell_sec_tls.h b/cell/api/u_cell_sec_tls.h index 5224765d..68d4a1fd 100644 --- a/cell/api/u_cell_sec_tls.h +++ b/cell/api/u_cell_sec_tls.h @@ -90,6 +90,18 @@ typedef struct { at the end to improve structure packing. */ } uCellSecTlsContext_t; +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uCellSecTlsPrivateLink(void); + /* ---------------------------------------------------------------- * FUNCTIONS: ADD/REMOVE A TLS SECURITY CONTEXT * -------------------------------------------------------------- */ diff --git a/cell/api/u_cell_sock.h b/cell/api/u_cell_sock.h index 7f586c3e..e49d25ae 100644 --- a/cell/api/u_cell_sock.h +++ b/cell/api/u_cell_sock.h @@ -84,6 +84,18 @@ extern "C" { * TYPES * -------------------------------------------------------------- */ +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uCellSockPrivateLink(void); + /* ---------------------------------------------------------------- * FUNCTIONS: INIT/DEINIT * -------------------------------------------------------------- */ diff --git a/cell/src/u_cell.c b/cell/src/u_cell.c index fa7f528b..80bfa9b8 100644 --- a/cell/src/u_cell.c +++ b/cell/src/u_cell.c @@ -51,6 +51,19 @@ #include "u_cell_net.h" // important here #include "u_cell_private.h" // don't change it +// The headers below necessary to work around an Espressif linker problem, see uCellInit() +#include "u_device_private_cell.h" +#include "u_network.h" +#include "u_network_config_cell.h" +#include "u_network_private_cell.h" +#include "u_sock.h" +#include "u_cell_sock.h" // For uCellSockPrivateLink() +#include "u_cell_sec.h" // For uCellSecPrivateLink() +#include "u_cell_sec_tls.h" // For uCellSecTlsPrivateLink() +#include "u_cell_mqtt.h" // For uCellMqttPrivateLink() +#include "u_cell_http.h" // For uCellHttpPrivateLink() +#include "u_cell_loc.h" // For uCellLocPrivateLink() + /* ---------------------------------------------------------------- * COMPILE-TIME MACROS * -------------------------------------------------------------- */ @@ -145,6 +158,24 @@ int32_t uCellInit() { int32_t errorCode = (int32_t) U_ERROR_COMMON_SUCCESS; + // Workaround for Espressif linker missing out files that + // only contain functions which also have weak alternatives + // (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + // Basically any file that might end up containing only functions + // that also have WEAK linked counterparts will be lost, so we need + // to add a dummy function in those files and call it from somewhere + // that will always be present in the build, which for cellular we + // choose to be here + uDevicePrivateCellLink(); + uNetworkPrivateCellLink(); + uCellSockPrivateLink(); + uCellSecPrivateLink(); + uCellSecTlsPrivateLink(); + uCellMqttPrivateLink(); + uCellHttpPrivateLink(); + uCellLocPrivateLink(); + + if (gUCellPrivateMutex == NULL) { // Create the mutex that protects the linked list errorCode = uPortMutexCreate(&gUCellPrivateMutex); diff --git a/cell/src/u_cell_http.c b/cell/src/u_cell_http.c index 09af39a6..8ce09c24 100644 --- a/cell/src/u_cell_http.c +++ b/cell/src/u_cell_http.c @@ -420,6 +420,15 @@ static void UUHTTPCR_urc(uAtClientHandle_t atHandle, void *pParameter) } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uCellHttpPrivateLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/cell/src/u_cell_loc.c b/cell/src/u_cell_loc.c index 910c4de6..ab401c6c 100644 --- a/cell/src/u_cell_loc.c +++ b/cell/src/u_cell_loc.c @@ -627,6 +627,15 @@ static int32_t beginLocationFix(const uCellPrivateInstance_t *pInstance) return errorCode; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uCellLocPrivateLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS: MISC * -------------------------------------------------------------- */ diff --git a/cell/src/u_cell_mqtt.c b/cell/src/u_cell_mqtt.c index 05234e7f..e98c997e 100644 --- a/cell/src/u_cell_mqtt.c +++ b/cell/src/u_cell_mqtt.c @@ -2057,6 +2057,15 @@ static int32_t readMessage(const uCellPrivateInstance_t *pInstance, return errorCode; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uCellMqttPrivateLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS: MQTT AND MQTT-SN * -------------------------------------------------------------- */ diff --git a/cell/src/u_cell_sec.c b/cell/src/u_cell_sec.c index cd03fda1..04e60a2f 100644 --- a/cell/src/u_cell_sec.c +++ b/cell/src/u_cell_sec.c @@ -315,6 +315,15 @@ static size_t encryptC2cConfirmationTag(const char *pC2cConfirmationTagHex, return length; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uCellSecPrivateLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS: INFORMATION * -------------------------------------------------------------- */ diff --git a/cell/src/u_cell_sec_tls.c b/cell/src/u_cell_sec_tls.c index 2830ac6b..bf94aeb1 100644 --- a/cell/src/u_cell_sec_tls.c +++ b/cell/src/u_cell_sec_tls.c @@ -568,6 +568,15 @@ static int32_t setGeneratePsk(const uCellSecTlsContext_t *pContext, return errorCode; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uCellSecTlsPrivateLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS: ADD/REMOVE A TLS SECURITY CONTEXT * -------------------------------------------------------------- */ diff --git a/cell/src/u_cell_sock.c b/cell/src/u_cell_sock.c index f1b8ceb5..cc822e9c 100644 --- a/cell/src/u_cell_sock.c +++ b/cell/src/u_cell_sock.c @@ -650,6 +650,15 @@ static int32_t doUsoctl(uDeviceHandle_t cellHandle, int32_t sockHandle, return negErrnoLocallOrValue; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uCellSockPrivateLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS: INIT/DEINIT * -------------------------------------------------------------- */ diff --git a/common/at_client/src/u_at_client_stub_short_range.c b/common/at_client/src/u_at_client_stub_short_range.c new file mode 100644 index 00000000..227efc7f --- /dev/null +++ b/common/at_client/src/u_at_client_stub_short_range.c @@ -0,0 +1,95 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/** @file + * @brief Stubs to allow the AT client to compile without short-range. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_short_range_pbuf.h" +#include "u_short_range_module_type.h" +#include "u_short_range.h" +#include "u_short_range_edm_stream.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +//lint -esym(593, pParam) Suppress pParam not being freed here +U_WEAK int32_t uShortRangeEdmStreamAtCallbackSet(int32_t handle, + uEdmAtEventCallback_t pFunction, + void *pParam) +{ + (void) handle; + (void) pFunction; + (void) pParam; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK void uShortRangeEdmStreamAtCallbackRemove(int32_t handle) +{ + (void) handle; +} + +U_WEAK void uShortRangeEdmStreamIpEventCallbackRemove(int32_t handle) +{ + (void) handle; +} + +U_WEAK int32_t uShortRangeEdmStreamAtRead(int32_t handle, void *pBuffer, + size_t sizeBytes) +{ + (void) handle; + (void) pBuffer; + (void) sizeBytes; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uShortRangeEdmStreamAtEventSend(int32_t handle, uint32_t eventBitMap) +{ + (void) handle; + (void) eventBitMap; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK bool uShortRangeEdmStreamAtEventIsCallback(int32_t handle) +{ + (void) handle; + return false; +} + +U_WEAK int32_t uShortRangeEdmStreamAtEventStackMinFree(int32_t handle) +{ + (void) handle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uShortRangeEdmStreamAtGetReceiveSize(int32_t handle) +{ + (void) handle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +// End of file diff --git a/common/device/src/u_device.c b/common/device/src/u_device.c index 9f2e6ba0..8204b45a 100644 --- a/common/device/src/u_device.c +++ b/common/device/src/u_device.c @@ -103,24 +103,28 @@ int32_t uDeviceInit() if (errorCode == 0) { uDevicePrivateInit(); errorCode = uDevicePrivateCellInit(); - if (errorCode == (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED) { + if ((errorCode == (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED) || + (errorCode == (int32_t) U_ERROR_COMMON_NOT_SUPPORTED)) { errorCode = 0; } } if (errorCode == 0) { errorCode = uDevicePrivateGnssInit(); - if (errorCode == (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED) { + if ((errorCode == (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED) || + (errorCode == (int32_t) U_ERROR_COMMON_NOT_SUPPORTED)) { errorCode = 0; } } if (errorCode == 0) { errorCode = uDevicePrivateShortRangeInit(); - if (errorCode == (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED) { + if ((errorCode == (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED) || + (errorCode == (int32_t) U_ERROR_COMMON_NOT_SUPPORTED)) { errorCode = 0; } } - if ((errorCode == 0) || (errorCode == (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED)) { + if ((errorCode == 0) || (errorCode == (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED) || + (errorCode == (int32_t) U_ERROR_COMMON_NOT_SUPPORTED)) { // Initialise the internally shared location API errorCode = uLocationSharedInit(); } diff --git a/common/device/src/u_device_private_cell.c b/common/device/src/u_device_private_cell.c index 71b2d1fa..1bc896fa 100644 --- a/common/device/src/u_device_private_cell.c +++ b/common/device/src/u_device_private_cell.c @@ -202,6 +202,15 @@ static int32_t addDevice(const uDeviceCfgUart_t *pCfgUart, return errorCode; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uDevicePrivateCellLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/device/src/u_device_private_cell.h b/common/device/src/u_device_private_cell.h index c2ab8efe..9984e520 100644 --- a/common/device/src/u_device_private_cell.h +++ b/common/device/src/u_device_private_cell.h @@ -48,6 +48,12 @@ extern "C" { * FUNCTIONS * -------------------------------------------------------------- */ +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + */ +void uDevicePrivateCellLink(void); + /** Initialise cellular. If cellular is already initialised * this function will return without doing anything. * diff --git a/common/device/src/u_device_private_cell_stub.c b/common/device/src/u_device_private_cell_stub.c index 1c185e52..8c5fd1c9 100644 --- a/common/device/src/u_device_private_cell_stub.c +++ b/common/device/src/u_device_private_cell_stub.c @@ -15,9 +15,11 @@ */ /** @file - * @brief Stub of the cellular portion of the device API. - * Build this instead of u_device_private_cell.c if you want to - * avoid linking cellular features into your application. + * @brief Stubs to allow the device API to be compiled without cellular; + * if you call a cellular API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when cellular is not included in the + * build. */ #ifdef U_CFG_OVERRIDE @@ -28,53 +30,38 @@ #include "stdint.h" // int32_t etc. #include "stdbool.h" +#include "u_compiler.h" // U_WEAK #include "u_error_common.h" #include "u_device.h" #include "u_device_shared.h" -/* ---------------------------------------------------------------- - * COMPILE-TIME MACROS - * -------------------------------------------------------------- */ - -/* ---------------------------------------------------------------- - * TYPES - * -------------------------------------------------------------- */ - -/* ---------------------------------------------------------------- - * STATIC VARIABLES - * -------------------------------------------------------------- */ - -/* ---------------------------------------------------------------- - * STATIC FUNCTIONS - * -------------------------------------------------------------- */ - /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ -int32_t uDevicePrivateCellInit() +U_WEAK int32_t uDevicePrivateCellInit() { - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -void uDevicePrivateCellDeinit() +U_WEAK void uDevicePrivateCellDeinit() { } -int32_t uDevicePrivateCellAdd(const uDeviceCfg_t *pDevCfg, - uDeviceHandle_t *pDeviceHandle) +U_WEAK int32_t uDevicePrivateCellAdd(const uDeviceCfg_t *pDevCfg, + uDeviceHandle_t *pDeviceHandle) { (void) pDevCfg; (void) pDeviceHandle; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED;; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -int32_t uDevicePrivateCellRemove(uDeviceHandle_t devHandle, - bool powerOff) +U_WEAK int32_t uDevicePrivateCellRemove(uDeviceHandle_t devHandle, + bool powerOff) { (void) devHandle; (void) powerOff; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED;; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } // End of file diff --git a/common/device/src/u_device_private_gnss.c b/common/device/src/u_device_private_gnss.c index 2cf06535..8eaba459 100644 --- a/common/device/src/u_device_private_gnss.c +++ b/common/device/src/u_device_private_gnss.c @@ -161,6 +161,15 @@ static int32_t addDevice(int32_t transportHandle, return errorCode; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uDevicePrivateGnssLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/device/src/u_device_private_gnss.h b/common/device/src/u_device_private_gnss.h index 89651154..503b5be1 100644 --- a/common/device/src/u_device_private_gnss.h +++ b/common/device/src/u_device_private_gnss.h @@ -48,6 +48,12 @@ extern "C" { * FUNCTIONS * -------------------------------------------------------------- */ +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + */ +void uDevicePrivateGnssLink(void); + /** Initialise GNSS. If GNSS is already initialised this function * will return without doing anything. * diff --git a/common/device/src/u_device_private_gnss_stub.c b/common/device/src/u_device_private_gnss_stub.c index 2a5f3969..89d64879 100644 --- a/common/device/src/u_device_private_gnss_stub.c +++ b/common/device/src/u_device_private_gnss_stub.c @@ -15,9 +15,11 @@ */ /** @file - * @brief Stub of the GNSS portion of the device API. - * Build this instead of u_device_private_gnss.c if you want to avoid - * linking GNSS features into your application. + * @brief Stubs to allow the device API to be compiled without GNSS; if + * you call a GNSS API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when GNSS is not included in the + * build. */ #ifdef U_CFG_OVERRIDE @@ -28,53 +30,38 @@ #include "stdint.h" // int32_t etc. #include "stdbool.h" +#include "u_compiler.h" // U_WEAK #include "u_error_common.h" #include "u_device.h" #include "u_device_shared.h" -/* ---------------------------------------------------------------- - * COMPILE-TIME MACROS - * -------------------------------------------------------------- */ - -/* ---------------------------------------------------------------- - * TYPES - * -------------------------------------------------------------- */ - -/* ---------------------------------------------------------------- - * STATIC VARIABLES - * -------------------------------------------------------------- */ - -/* ---------------------------------------------------------------- - * STATIC FUNCTIONS - * -------------------------------------------------------------- */ - /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ -int32_t uDevicePrivateGnssInit() +U_WEAK int32_t uDevicePrivateGnssInit() { - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -void uDevicePrivateGnssDeinit() +U_WEAK void uDevicePrivateGnssDeinit() { } -int32_t uDevicePrivateGnssAdd(const uDeviceCfg_t *pDevCfg, - uDeviceHandle_t *pDeviceHandle) +U_WEAK int32_t uDevicePrivateGnssAdd(const uDeviceCfg_t *pDevCfg, + uDeviceHandle_t *pDeviceHandle) { (void) pDevCfg; (void) pDeviceHandle; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED;; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -int32_t uDevicePrivateGnssRemove(uDeviceHandle_t devHandle, - bool powerOff) +U_WEAK int32_t uDevicePrivateGnssRemove(uDeviceHandle_t devHandle, + bool powerOff) { (void) devHandle; (void) powerOff; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED;; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } // End of file diff --git a/common/device/src/u_device_private_short_range.c b/common/device/src/u_device_private_short_range.c index 18f9c695..ed7670e8 100644 --- a/common/device/src/u_device_private_short_range.c +++ b/common/device/src/u_device_private_short_range.c @@ -61,6 +61,21 @@ * STATIC FUNCTIONS * -------------------------------------------------------------- */ +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/* If this file turns out to only have functions in it that also have + * WEAK alternatives then the Espressif linker may ignore the entire + * file (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * To fix this we declare a dummy function here which the CMake file + * for ESP-IDF forces the linker to take notice of. + */ +void uDevicePrivateShortRangeLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/device/src/u_device_private_short_range.h b/common/device/src/u_device_private_short_range.h index d7c74ad0..20cfea93 100644 --- a/common/device/src/u_device_private_short_range.h +++ b/common/device/src/u_device_private_short_range.h @@ -49,6 +49,12 @@ extern "C" { * FUNCTIONS * -------------------------------------------------------------- */ +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + */ +void uDevicePrivateShortRangeLink(void); + /** Initialise short-range. If short-range is already initialised * this function will return without doing anything. * diff --git a/common/device/src/u_device_private_short_range_stub.c b/common/device/src/u_device_private_short_range_stub.c index 23d3e6b0..081bd9fe 100644 --- a/common/device/src/u_device_private_short_range_stub.c +++ b/common/device/src/u_device_private_short_range_stub.c @@ -15,9 +15,11 @@ */ /** @file - * @brief Stub of the short-range portion of the device API. - * Build this instead of u_device_private_short_range.c if you want to - * avoid linking short-range features into your application. + * @brief Stubs to allow the device API to be compiled without short range; + * if you call a short range API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when short range is not included in the + * build. */ #ifdef U_CFG_OVERRIDE @@ -28,65 +30,50 @@ #include "stdint.h" // int32_t etc. #include "stdbool.h" +#include "u_compiler.h" // U_WEAK #include "u_error_common.h" #include "u_device.h" #include "u_device_shared.h" -/* ---------------------------------------------------------------- - * COMPILE-TIME MACROS - * -------------------------------------------------------------- */ - -/* ---------------------------------------------------------------- - * TYPES - * -------------------------------------------------------------- */ - -/* ---------------------------------------------------------------- - * STATIC VARIABLES - * -------------------------------------------------------------- */ - -/* ---------------------------------------------------------------- - * STATIC FUNCTIONS - * -------------------------------------------------------------- */ - /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ -int32_t uDevicePrivateShortRangeInit() +U_WEAK int32_t uDevicePrivateShortRangeInit() { - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -void uDevicePrivateShortRangeDeinit() +U_WEAK void uDevicePrivateShortRangeDeinit() { } -int32_t uDevicePrivateShortRangeAdd(const uDeviceCfg_t *pDevCfg, - uDeviceHandle_t *pDeviceHandle) +U_WEAK int32_t uDevicePrivateShortRangeAdd(const uDeviceCfg_t *pDevCfg, + uDeviceHandle_t *pDeviceHandle) { (void) pDevCfg; (void) pDeviceHandle; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED;; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -int32_t uDevicePrivateShortRangeOpenCpuAdd(const uDeviceCfg_t *pDevCfg, - uDeviceHandle_t *pDeviceHandle) +U_WEAK int32_t uDevicePrivateShortRangeOpenCpuAdd(const uDeviceCfg_t *pDevCfg, + uDeviceHandle_t *pDeviceHandle) { (void) pDevCfg; (void) pDeviceHandle; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED;; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -int32_t uDevicePrivateShortRangeRemove(uDeviceHandle_t devHandle) +U_WEAK int32_t uDevicePrivateShortRangeRemove(uDeviceHandle_t devHandle) { (void) devHandle; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED;; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -int32_t uDevicePrivateShortRangeOpenCpuRemove(uDeviceHandle_t devHandle) +U_WEAK int32_t uDevicePrivateShortRangeOpenCpuRemove(uDeviceHandle_t devHandle) { (void) devHandle; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED;; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } // End of file diff --git a/common/http_client/src/u_http_client_stub_cell.c b/common/http_client/src/u_http_client_stub_cell.c new file mode 100644 index 00000000..35e82b42 --- /dev/null +++ b/common/http_client/src/u_http_client_stub_cell.c @@ -0,0 +1,182 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the HTTP Client API to be compiled without cellular; + * if you call a cellular API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when cellular is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_at_client.h" +#include "u_device.h" +#include "u_cell_module_type.h" +#include "u_cell.h" +#include "u_cell_file.h" +#include "u_cell_http.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uCellFileWrite(uDeviceHandle_t cellHandle, + const char *pFileName, + const char *pData, + size_t dataSize) +{ + (void) cellHandle; + (void) pFileName; + (void) pData; + (void) dataSize; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellFileBlockRead(uDeviceHandle_t cellHandle, + const char *pFileName, + char *pData, + size_t offset, + size_t dataSize) +{ + (void) cellHandle; + (void) pFileName; + (void) pData; + (void) offset; + (void) dataSize; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellFileDelete(uDeviceHandle_t cellHandle, + const char *pFileName) +{ + (void) cellHandle; + (void) pFileName; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellFileListFirst_r(uDeviceHandle_t cellHandle, + char *pFileName, void **ppRentrant) +{ + (void) cellHandle; + (void) pFileName; + (void) ppRentrant; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellFileListNext_r(char *pFileName, void **ppRentrant) +{ + (void) pFileName; + (void) ppRentrant; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK void uCellFileListLast_r(void **ppRentrant) +{ + (void) ppRentrant; +} + +U_WEAK int32_t uCellAtClientHandleGet(uDeviceHandle_t cellHandle, + uAtClientHandle_t *pAtHandle) +{ + (void) cellHandle; + (void) pAtHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellHttpOpen(uDeviceHandle_t cellHandle, const char *pServerName, + const char *pUserName, const char *pPassword, + int32_t timeoutSeconds, uCellHttpCallback_t *pCallback, + void *pCallbackParam) +{ + (void) cellHandle; + (void) pServerName; + (void) pUserName; + (void) pPassword; + (void) timeoutSeconds; + (void) pCallback; + (void) pCallbackParam; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK void uCellHttpClose(uDeviceHandle_t cellHandle, int32_t httpHandle) +{ + (void) cellHandle; + (void) httpHandle; +} + +U_WEAK int32_t uCellHttpSetSecurityOn(uDeviceHandle_t cellHandle, int32_t httpHandle, + int32_t securityProfileId) +{ + (void) cellHandle; + (void) httpHandle; + (void) securityProfileId; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellHttpSetSecurityOff(uDeviceHandle_t cellHandle, int32_t httpHandle) +{ + (void) cellHandle; + (void) httpHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellHttpRequest(uDeviceHandle_t cellHandle, int32_t httpHandle, + uCellHttpRequest_t requestType, + const char *pPath, const char *pFileNameResponse, + const char *pStrPost, const char *pContentTypePost) +{ + (void) cellHandle; + (void) httpHandle; + (void) requestType; + (void) pPath; + (void) pFileNameResponse; + (void) pStrPost; + (void) pContentTypePost; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellHttpRequestFile(uDeviceHandle_t cellHandle, int32_t httpHandle, + uCellHttpRequest_t requestType, + const char *pPath, const char *pFileNameResponse, + const char *pFileNamePutPost, + const char *pContentTypePutPost) +{ + (void) cellHandle; + (void) httpHandle; + (void) requestType; + (void) pPath; + (void) pFileNameResponse; + (void) pFileNamePutPost; + (void) pContentTypePutPost; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +// End of file diff --git a/common/http_client/src/u_http_client_stub_wifi.c b/common/http_client/src/u_http_client_stub_wifi.c new file mode 100644 index 00000000..db2bbb53 --- /dev/null +++ b/common/http_client/src/u_http_client_stub_wifi.c @@ -0,0 +1,46 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the HTTP Client API to be compiled without Wi-Fi; + * if you call a Wi-Fi API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when Wi-Fi is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +// End of file diff --git a/common/location/src/u_location_stub_cell.c b/common/location/src/u_location_stub_cell.c new file mode 100644 index 00000000..33d3ecc8 --- /dev/null +++ b/common/location/src/u_location_stub_cell.c @@ -0,0 +1,127 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the Location API to be compiled without cellular; + * if you call a cellular API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when cellular is not included in the + * build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" +#include "u_cell_loc.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK void uCellLocSetDesiredAccuracy(uDeviceHandle_t cellHandle, + int32_t accuracyMillimetres) +{ + (void) cellHandle; + (void) accuracyMillimetres; +} + +U_WEAK void uCellLocSetDesiredFixTimeout(uDeviceHandle_t cellHandle, + int32_t fixTimeoutSeconds) +{ + (void) cellHandle; + (void) fixTimeoutSeconds; +} + +U_WEAK void uCellLocSetGnssEnable(uDeviceHandle_t cellHandle, bool onNotOff) +{ + (void) cellHandle; + (void) onNotOff; +} + +U_WEAK int32_t uCellLocSetServer(uDeviceHandle_t cellHandle, + const char *pAuthenticationTokenStr, + const char *pPrimaryServerStr, + const char *pSecondaryServerStr) +{ + (void) cellHandle; + (void) pAuthenticationTokenStr; + (void) pPrimaryServerStr; + (void) pSecondaryServerStr; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellLocGet(uDeviceHandle_t cellHandle, + int32_t *pLatitudeX1e7, int32_t *pLongitudeX1e7, + int32_t *pAltitudeMillimetres, int32_t *pRadiusMillimetres, + int32_t *pSpeedMillimetresPerSecond, + int32_t *pSvs, + int64_t *pTimeUtc, + bool (*pKeepGoingCallback) (uDeviceHandle_t)) +{ + (void) cellHandle; + (void) pLatitudeX1e7; + (void) pLongitudeX1e7; + (void) pAltitudeMillimetres; + (void) pRadiusMillimetres; + (void) pSpeedMillimetresPerSecond; + (void) pSvs; + (void) pTimeUtc; + (void) pKeepGoingCallback; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellLocGetStart(uDeviceHandle_t cellHandle, + void (*pCallback) (uDeviceHandle_t cellHandle, + int32_t errorCode, + int32_t latitudeX1e7, + int32_t longitudeX1e7, + int32_t altitudeMillimetres, + int32_t radiusMillimetres, + int32_t speedMillimetresPerSecond, + int32_t svs, + int64_t timeUtc)) +{ + (void) cellHandle; + (void) pCallback; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellLocGetStatus(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK void uCellLocGetStop(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; +} + +// End of file diff --git a/common/location/src/u_location_stub_gnss.c b/common/location/src/u_location_stub_gnss.c new file mode 100644 index 00000000..a227c2a4 --- /dev/null +++ b/common/location/src/u_location_stub_gnss.c @@ -0,0 +1,106 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the Location API to be compiled without GNSS; + * if you call a GNSS API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED for when GNSS is not included in the + * build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_gnss_pos.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uGnssPosGet(uDeviceHandle_t gnssHandle, + int32_t *pLatitudeX1e7, int32_t *pLongitudeX1e7, + int32_t *pAltitudeMillimetres, + int32_t *pRadiusMillimetres, + int32_t *pSpeedMillimetresPerSecond, + int32_t *pSvs, int64_t *pTimeUtc, + bool (*pKeepGoingCallback) (uDeviceHandle_t)) +{ + (void) gnssHandle; + (void) pLatitudeX1e7; + (void) pLongitudeX1e7; + (void) pAltitudeMillimetres; + (void) pRadiusMillimetres; + (void) pSpeedMillimetresPerSecond; + (void) pSvs; + (void) pTimeUtc; + (void) pKeepGoingCallback; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uGnssPosGetStart(uDeviceHandle_t gnssHandle, + void (*pCallback) (uDeviceHandle_t gnssHandle, + int32_t errorCode, + int32_t latitudeX1e7, + int32_t longitudeX1e7, + int32_t altitudeMillimetres, + int32_t radiusMillimetres, + int32_t speedMillimetresPerSecond, + int32_t svs, + int64_t timeUtc)) +{ + (void) gnssHandle; + (void) pCallback; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK void uGnssPosGetStop(uDeviceHandle_t gnssHandle) +{ + (void) gnssHandle; +} + +U_WEAK int32_t uGnssPosGetRrlp(uDeviceHandle_t gnssHandle, char *pBuffer, + size_t sizeBytes, int32_t svsThreshold, + int32_t cNoThreshold, + int32_t multipathIndexLimit, + int32_t pseudorangeRmsErrorIndexLimit, + bool (*pKeepGoingCallback) (uDeviceHandle_t)) +{ + (void) gnssHandle; + (void) pBuffer; + (void) sizeBytes; + (void) svsThreshold; + (void) cNoThreshold; + (void) multipathIndexLimit; + (void) pseudorangeRmsErrorIndexLimit; + (void) pKeepGoingCallback; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +// End of file diff --git a/common/mqtt_client/src/u_mqtt_client.c b/common/mqtt_client/src/u_mqtt_client.c index c702463f..71ff68c2 100644 --- a/common/mqtt_client/src/u_mqtt_client.c +++ b/common/mqtt_client/src/u_mqtt_client.c @@ -191,7 +191,7 @@ uMqttClientContext_t *pUMqttClientOpen(uDeviceHandle_t devHandle, pContext->totalMessagesSent = 0; pContext->totalMessagesReceived = 0; pContext->pPriv = pPriv; - if (uPortMutexCreate((uPortMutexHandle_t *) & (pContext->mutexHandle)) == 0) { + if (uPortMutexCreate((uPortMutexHandle_t *) &(pContext->mutexHandle)) == 0) { // *NOPAD* gLastOpenError = U_ERROR_COMMON_SUCCESS; if (pSecurityTlsSettings != NULL) { // Call the common security layer diff --git a/common/mqtt_client/src/u_mqtt_client_stub_cell.c b/common/mqtt_client/src/u_mqtt_client_stub_cell.c new file mode 100644 index 00000000..e309bfb6 --- /dev/null +++ b/common/mqtt_client/src/u_mqtt_client_stub_cell.c @@ -0,0 +1,325 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the MQTT Client API to be compiled without cellular; + * if you call a cellular API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when cellular is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" +#include "u_cell_mqtt.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uCellMqttInit(uDeviceHandle_t cellHandle, const char *pBrokerNameStr, + const char *pClientIdStr, const char *pUserNameStr, + const char *pPasswordStr, + bool (*pKeepGoingCallback)(void), + bool mqttSn) +{ + (void) cellHandle; + (void) pBrokerNameStr; + (void) pClientIdStr; + (void) pUserNameStr; + (void) pPasswordStr; + (void) pKeepGoingCallback; + (void) mqttSn; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK void uCellMqttDeinit(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; +} + +U_WEAK int32_t uCellMqttSetLocalPort(uDeviceHandle_t cellHandle, uint16_t port) +{ + (void) cellHandle; + (void) port; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSetInactivityTimeout(uDeviceHandle_t cellHandle, + size_t seconds) +{ + (void) cellHandle; + (void) seconds; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSetKeepAliveOn(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSetRetainOn(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSetSecurityOn(uDeviceHandle_t cellHandle, + int32_t securityProfileId) +{ + (void) cellHandle; + (void) securityProfileId; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSetWill(uDeviceHandle_t cellHandle, + const char *pTopicNameStr, + const char *pMessage, + size_t messageSizeBytes, + uCellMqttQos_t qos, bool retain) +{ + (void) cellHandle; + (void) pTopicNameStr; + (void) pMessage; + (void) messageSizeBytes; + (void) qos; + (void) retain; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttConnect(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttDisconnect(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK bool uCellMqttIsConnected(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return false; +} + +U_WEAK int32_t uCellMqttSetMessageCallback(uDeviceHandle_t cellHandle, + void (*pCallback) (int32_t, void *), + void *pCallbackParam) +{ + (void) cellHandle; + (void) pCallback; + (void) pCallbackParam; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttGetUnread(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttGetLastErrorCode(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSetDisconnectCallback(uDeviceHandle_t cellHandle, + void (*pCallback) (int32_t, void *), + void *pCallbackParam) +{ + (void) cellHandle; + (void) pCallback; + (void) pCallbackParam; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK bool uCellMqttIsSupported(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return false; +} + +U_WEAK int32_t uCellMqttPublish(uDeviceHandle_t cellHandle, + const char *pTopicNameStr, + const char *pMessage, + size_t messageSizeBytes, + uCellMqttQos_t qos, bool retain) +{ + (void) cellHandle; + (void) pTopicNameStr; + (void) pMessage; + (void) messageSizeBytes; + (void) qos; + (void) retain; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSubscribe(uDeviceHandle_t cellHandle, + const char *pTopicFilterStr, + uCellMqttQos_t maxQos) +{ + (void) cellHandle; + (void) pTopicFilterStr; + (void) maxQos; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttUnsubscribe(uDeviceHandle_t cellHandle, + const char *pTopicFilterStr) +{ + (void) cellHandle; + (void) pTopicFilterStr; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttMessageRead(uDeviceHandle_t cellHandle, + char *pTopicNameStr, + size_t topicNameSizeBytes, + char *pMessage, size_t *pMessageSizeBytes, + uCellMqttQos_t *pQos) +{ + (void) cellHandle; + (void) pTopicNameStr; + (void) topicNameSizeBytes; + (void) pMessage; + (void) pMessageSizeBytes; + (void) pQos; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK bool uCellMqttSnIsSupported(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return false; +} + +U_WEAK int32_t uCellMqttSnRegisterNormalTopic(uDeviceHandle_t cellHandle, + const char *pTopicNameStr, + uCellMqttSnTopicName_t *pTopicName) +{ + (void) cellHandle; + (void) pTopicNameStr; + (void) pTopicName; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSnPublish(uDeviceHandle_t cellHandle, + const uCellMqttSnTopicName_t *pTopicName, + const char *pMessage, + size_t messageSizeBytes, + uCellMqttQos_t qos, bool retain) +{ + (void) cellHandle; + (void) pTopicName; + (void) pMessage; + (void) messageSizeBytes; + (void) qos; + (void) retain; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSnSubscribe(uDeviceHandle_t cellHandle, + const uCellMqttSnTopicName_t *pTopicName, + uCellMqttQos_t maxQos) +{ + (void) cellHandle; + (void) pTopicName; + (void) maxQos; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSnSubscribeNormalTopic(uDeviceHandle_t cellHandle, + const char *pTopicFilterStr, + uCellMqttQos_t maxQos, + uCellMqttSnTopicName_t *pTopicName) +{ + (void) cellHandle; + (void) pTopicFilterStr; + (void) maxQos; + (void) pTopicName; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSnUnsubscribe(uDeviceHandle_t cellHandle, + const uCellMqttSnTopicName_t *pTopicName) +{ + (void) cellHandle; + (void) pTopicName; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSnUnsubscribeNormalTopic(uDeviceHandle_t cellHandle, + const char *pTopicFilterStr) +{ + (void) cellHandle; + (void) pTopicFilterStr; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSnMessageRead(uDeviceHandle_t cellHandle, + uCellMqttSnTopicName_t *pTopicName, + char *pMessage, size_t *pMessageSizeBytes, + uCellMqttQos_t *pQos) +{ + (void) cellHandle; + (void) pTopicName; + (void) pMessage; + (void) pMessageSizeBytes; + (void) pQos; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSnSetWillMessaage(uDeviceHandle_t cellHandle, + const char *pMessage, + size_t messageSizeBytes) +{ + (void) cellHandle; + (void) pMessage; + (void) messageSizeBytes; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellMqttSnSetWillParameters(uDeviceHandle_t cellHandle, + const char *pTopicNameStr, + uCellMqttQos_t qos, bool retain) +{ + (void) cellHandle; + (void) pTopicNameStr; + (void) qos; + (void) retain; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +// End of file diff --git a/common/mqtt_client/src/u_mqtt_client_stub_wifi.c b/common/mqtt_client/src/u_mqtt_client_stub_wifi.c new file mode 100644 index 00000000..0edab3a9 --- /dev/null +++ b/common/mqtt_client/src/u_mqtt_client_stub_wifi.c @@ -0,0 +1,157 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the MQTT Client API to be compiled without Wi-Fi; + * if you call a Wi-Fi API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when Wi-Fi is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" +#include "u_mqtt_common.h" +#include "u_mqtt_client.h" +#include "u_wifi_mqtt.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uWifiMqttInit(uDeviceHandle_t devHandle, void **ppMqttSession) +{ + (void) devHandle; + (void) ppMqttSession; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK void uWifiMqttClose(uMqttClientContext_t *pContext) +{ + (void) pContext; +} + +U_WEAK int32_t uWifiMqttConnect(const uMqttClientContext_t *pContext, + const uMqttClientConnection_t *pConnection) +{ + (void) pContext; + (void) pConnection; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uWifiMqttDisconnect(const uMqttClientContext_t *pContext) +{ + (void) pContext; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK bool uWifiMqttIsConnected(const uMqttClientContext_t *pContext) +{ + (void) pContext; + return false; +} + +U_WEAK int32_t uWifiMqttSetMessageCallback(const uMqttClientContext_t *pContext, + void (*pCallback) (int32_t, void *), + void *pCallbackParam) +{ + (void) pContext; + (void) pCallback; + (void) pCallbackParam; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uWifiMqttGetUnread(const uMqttClientContext_t *pContext) +{ + (void) pContext; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uWifiMqttSetDisconnectCallback(const uMqttClientContext_t *pContext, + void (*pCallback) (int32_t, void *), + void *pCallbackParam) +{ + (void) pContext; + (void) pCallback; + (void) pCallbackParam; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uWifiMqttPublish(const uMqttClientContext_t *pContext, + const char *pTopicNameStr, + const char *pMessage, + size_t messageSizeBytes, + uMqttQos_t qos, + bool retain) +{ + (void) pContext; + (void) pTopicNameStr; + (void) pMessage; + (void) messageSizeBytes; + (void) qos; + (void) retain; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uWifiMqttSubscribe(const uMqttClientContext_t *pContext, + const char *pTopicFilterStr, + uMqttQos_t maxQos) +{ + (void) pContext; + (void) pTopicFilterStr; + (void) maxQos; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uWifiMqttUnsubscribe(const uMqttClientContext_t *pContext, + const char *pTopicFilterStr) +{ + (void) pContext; + (void) pTopicFilterStr; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uWifiMqttMessageRead(const uMqttClientContext_t *pContext, + char *pTopicNameStr, + size_t topicNameSizeBytes, + char *pMessage, + size_t *pMessageSizeBytes, + uMqttQos_t *pQos) +{ + (void) pContext; + (void) pTopicNameStr; + (void) topicNameSizeBytes; + (void) pMessage; + (void) pMessageSizeBytes; + (void) pQos; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +// End of file diff --git a/common/network/src/u_network_private_ble.h b/common/network/src/u_network_private_ble.h index 8c8385d5..ecaf354b 100644 --- a/common/network/src/u_network_private_ble.h +++ b/common/network/src/u_network_private_ble.h @@ -44,6 +44,12 @@ extern "C" { * FUNCTIONS * -------------------------------------------------------------- */ +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + */ +void uNetworkPrivateBleLink(void); + /** Take up or down the given BLE network instance. uDeviceOpen() * must have been called first to create the device handle. * diff --git a/common/network/src/u_network_private_ble_extmod.c b/common/network/src/u_network_private_ble_extmod.c index f40fa8a0..ec8b5f15 100644 --- a/common/network/src/u_network_private_ble_extmod.c +++ b/common/network/src/u_network_private_ble_extmod.c @@ -123,6 +123,15 @@ static void statusCallback(int32_t connHandle, char *pAddress, } } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uNetworkPrivateBleLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/network/src/u_network_private_ble_extmod_stub.c b/common/network/src/u_network_private_ble_extmod_stub.c index 7d04b56a..e95f4f6a 100644 --- a/common/network/src/u_network_private_ble_extmod_stub.c +++ b/common/network/src/u_network_private_ble_extmod_stub.c @@ -21,16 +21,19 @@ */ /** @file - * @brief Stub of the ble portion of the network API. - * Include this if the ble network is not used in the application. + * @brief Stubs to allow the network API to be compiled without BLE; + * if you call a BLE API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when BLE is not included in the + * build. */ #include "stddef.h" // NULL, size_t etc. #include "stdint.h" // int32_t etc. #include "stdbool.h" +#include "u_compiler.h" // U_WEAK #include "u_error_common.h" - #include "u_network.h" #include "u_network_config_ble.h" #include "u_network_private_ble.h" @@ -39,20 +42,20 @@ * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ -int32_t uNetworkPrivateChangeStateBle(uDeviceHandle_t devHandle, - const uNetworkCfgBle_t *pCfg, - bool upNotDown) +U_WEAK int32_t uNetworkPrivateChangeStateBle(uDeviceHandle_t devHandle, + const uNetworkCfgBle_t *pCfg, + bool upNotDown) { (void) devHandle; (void) pCfg; (void) upNotDown; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -int32_t uNetworkSetStatusCallbackBle(uDeviceHandle_t devHandle) +U_WEAK int32_t uNetworkSetStatusCallbackBle(uDeviceHandle_t devHandle) { (void) devHandle; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } // End of file diff --git a/common/network/src/u_network_private_ble_intmod.c b/common/network/src/u_network_private_ble_intmod.c index 2dfff45a..b8ca3f7a 100644 --- a/common/network/src/u_network_private_ble_intmod.c +++ b/common/network/src/u_network_private_ble_intmod.c @@ -115,6 +115,15 @@ static void statusCallback(int32_t connHandle, char *pAddress, } } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uNetworkPrivateBleLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/network/src/u_network_private_cell.c b/common/network/src/u_network_private_cell.c index 85c3d3de..0e97a5aa 100644 --- a/common/network/src/u_network_private_cell.c +++ b/common/network/src/u_network_private_cell.c @@ -129,6 +129,21 @@ static void statusCallback(uCellNetRegDomain_t domain, } } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/* If this file turns out to only have functions in it that also have + * WEAK alternatives then the Espressif linker may ignore the entire + * file (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * To fix this we declare a dummy function here which the CMake file + * for ESP-IDF forces the linker to take notice of. + */ +void uNetworkPrivateCellLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/network/src/u_network_private_cell.h b/common/network/src/u_network_private_cell.h index 82fd6ccb..0f7c738a 100644 --- a/common/network/src/u_network_private_cell.h +++ b/common/network/src/u_network_private_cell.h @@ -45,6 +45,12 @@ extern "C" { * FUNCTIONS * -------------------------------------------------------------- */ +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + */ +void uNetworkPrivateCellLink(void); + /** Take up or down the given cellular network instance. uDeviceOpen() * must have been called first to create the device handle. * diff --git a/common/network/src/u_network_private_cell_stub.c b/common/network/src/u_network_private_cell_stub.c index 62333e77..58bf6c92 100644 --- a/common/network/src/u_network_private_cell_stub.c +++ b/common/network/src/u_network_private_cell_stub.c @@ -21,34 +21,61 @@ */ /** @file - * @brief Stub of the cellular portion of the network API. - * Include this if the cellular network is not used in the application. + * @brief Stubs to allow the network API to be compiled without cellular; + * if you call a cellular API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when cellular is not included in the + * build. */ #include "stddef.h" // NULL, size_t etc. #include "stdint.h" // int32_t etc. #include "stdbool.h" +#include "u_compiler.h" // U_WEAK #include "u_error_common.h" - #include "u_network.h" #include "u_network_config_cell.h" #include "u_network_private_cell.h" -int32_t uNetworkPrivateChangeStateCell(uDeviceHandle_t devHandle, - const uNetworkCfgCell_t *pCfg, - bool upNotDown) +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uNetworkPrivateChangeStateCell(uDeviceHandle_t devHandle, + const uNetworkCfgCell_t *pCfg, + bool upNotDown) { (void) devHandle; (void) pCfg; (void) upNotDown; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -int32_t uNetworkSetStatusCallbackCell(uDeviceHandle_t devHandle) +U_WEAK int32_t uNetworkSetStatusCallbackCell(uDeviceHandle_t devHandle) { (void) devHandle; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellLocSetPinGnssPwr(uDeviceHandle_t cellHandle, int32_t pin) +{ + (void) cellHandle; + (void) pin; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellLocSetPinGnssDataReady(uDeviceHandle_t cellHandle, int32_t pin) +{ + (void) cellHandle; + (void) pin; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK bool uCellLocGnssInsideCell(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return false; } // End of file diff --git a/common/network/src/u_network_private_gnss.c b/common/network/src/u_network_private_gnss.c index e95f42ec..69e9b6a5 100644 --- a/common/network/src/u_network_private_gnss.c +++ b/common/network/src/u_network_private_gnss.c @@ -93,6 +93,15 @@ static void setGnssDeviceHandle(uDeviceHandle_t devHandle, } } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uNetworkPrivateGnssLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/network/src/u_network_private_gnss.h b/common/network/src/u_network_private_gnss.h index 28dca16e..7b66ec34 100644 --- a/common/network/src/u_network_private_gnss.h +++ b/common/network/src/u_network_private_gnss.h @@ -44,6 +44,12 @@ extern "C" { * FUNCTIONS * -------------------------------------------------------------- */ +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + */ +void uNetworkPrivateGnssLink(void); + /** Take up or down the given GNSS network instance. uDeviceOpen() * must have been called first to create the device handle. * diff --git a/common/network/src/u_network_private_gnss_stub.c b/common/network/src/u_network_private_gnss_stub.c index f35490ee..2e0c4543 100644 --- a/common/network/src/u_network_private_gnss_stub.c +++ b/common/network/src/u_network_private_gnss_stub.c @@ -21,28 +21,34 @@ */ /** @file - * @brief Stub of the GNSS portion of the network API. - * Include this if the GNS network is not used in the application. + * @brief Stubs to allow the network API to be compiled without GNSS; + * if you call a GNSS API function from the source code here you must also + * include a weak stub for it which will return #U_ERROR_COMMON_NOT_SUPPORTED + * when GNSS is not included in the build. */ #include "stddef.h" // NULL, size_t etc. #include "stdint.h" // int32_t etc. #include "stdbool.h" +#include "u_compiler.h" // U_WEAK #include "u_error_common.h" - #include "u_network.h" #include "u_network_config_gnss.h" #include "u_network_private_gnss.h" -int32_t uNetworkPrivateChangeStateGnss(uDeviceHandle_t devHandle, - const uNetworkCfgGnss_t *pCfg, - bool upNotDown) +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uNetworkPrivateChangeStateGnss(uDeviceHandle_t devHandle, + const uNetworkCfgGnss_t *pCfg, + bool upNotDown) { (void) devHandle; (void) pCfg; (void) upNotDown; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } // End of file diff --git a/common/network/src/u_network_private_wifi.c b/common/network/src/u_network_private_wifi.c index 61cb95c1..19c5683d 100644 --- a/common/network/src/u_network_private_wifi.c +++ b/common/network/src/u_network_private_wifi.c @@ -322,6 +322,15 @@ static inline int32_t statusQueueWaitForNetworkUp(const uPortQueueHandle_t queue return (int32_t) U_ERROR_COMMON_TIMEOUT; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uNetworkPrivateWifiLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/network/src/u_network_private_wifi.h b/common/network/src/u_network_private_wifi.h index a4772a30..8fba127b 100644 --- a/common/network/src/u_network_private_wifi.h +++ b/common/network/src/u_network_private_wifi.h @@ -44,6 +44,12 @@ extern "C" { * FUNCTIONS * -------------------------------------------------------------- */ +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + */ +void uNetworkPrivateWifiLink(void); + /** Take up or down the given Wifi network instance. uDeviceOpen() * must have been called first to create the device handle. * diff --git a/common/network/src/u_network_private_wifi_stub.c b/common/network/src/u_network_private_wifi_stub.c index e8388caf..24adefff 100644 --- a/common/network/src/u_network_private_wifi_stub.c +++ b/common/network/src/u_network_private_wifi_stub.c @@ -21,16 +21,18 @@ */ /** @file - * @brief Stub of the wifi portion of the network API. - * Include this if the wifi network is not used in the application. + * @brief Stubs to allow the network API to be compiled without Wi-Fi; + * if you call a Wi-Fi API function from the source code here you must also + * include a weak stub for it which will return #U_ERROR_COMMON_NOT_SUPPORTED + * for when Wi-Fi is not included in the build. */ #include "stddef.h" // NULL, size_t etc. #include "stdint.h" // int32_t etc. #include "stdbool.h" +#include "u_compiler.h" // U_WEAK #include "u_error_common.h" - #include "u_network.h" #include "u_network_config_wifi.h" #include "u_network_private_wifi.h" @@ -39,19 +41,19 @@ * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ -int32_t uNetworkPrivateChangeStateWifi(uDeviceHandle_t devHandle, - const uNetworkCfgWifi_t *pCfg, - bool upNotDown) +U_WEAK int32_t uNetworkPrivateChangeStateWifi(uDeviceHandle_t devHandle, + const uNetworkCfgWifi_t *pCfg, + bool upNotDown) { (void) devHandle; (void) pCfg; (void) upNotDown; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } -int32_t uNetworkSetStatusCallbackWifi(uDeviceHandle_t devHandle) +U_WEAK int32_t uNetworkSetStatusCallbackWifi(uDeviceHandle_t devHandle) { (void) devHandle; - return (int32_t) U_ERROR_COMMON_NOT_IMPLEMENTED; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; } // End of file diff --git a/common/security/src/u_security_credential_stub_cell.c b/common/security/src/u_security_credential_stub_cell.c new file mode 100644 index 00000000..d3085c5c --- /dev/null +++ b/common/security/src/u_security_credential_stub_cell.c @@ -0,0 +1,57 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the Security Credential API to be compiled without + * cellular; if you call a cellular API function from the source code + * here you must also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when cellular is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_at_client.h" +#include "u_device.h" +#include "u_cell_module_type.h" +#include "u_cell.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uCellAtClientHandleGet(uDeviceHandle_t cellHandle, + uAtClientHandle_t *pAtHandle) +{ + (void) cellHandle; + (void) pAtHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +// End of file diff --git a/common/security/src/u_security_credential_stub_short_range.c b/common/security/src/u_security_credential_stub_short_range.c new file mode 100644 index 00000000..8dd1c42e --- /dev/null +++ b/common/security/src/u_security_credential_stub_short_range.c @@ -0,0 +1,56 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the Security Credential API to be compiled without + * short range; if you call a short range API function from the source code + * here you must also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when short range is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_at_client.h" +#include "u_device.h" +#include "u_short_range.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uShortRangeAtClientHandleGet(uDeviceHandle_t devHandle, + uAtClientHandle_t *pAtHandle) +{ + (void) devHandle; + (void) pAtHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +// End of file diff --git a/common/security/src/u_security_stub_cell.c b/common/security/src/u_security_stub_cell.c new file mode 100644 index 00000000..6805a325 --- /dev/null +++ b/common/security/src/u_security_stub_cell.c @@ -0,0 +1,195 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the Security API to be compiled without cellular; + * if you call a cellular API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when cellular is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" +#include "u_security.h" +#include "u_cell_sec.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK bool uCellSecIsSupported(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return false; +} + +U_WEAK bool uCellSecIsBootstrapped(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return false; +} + +U_WEAK int32_t uCellSecGetSerialNumber(uDeviceHandle_t cellHandle, + char *pSerialNumber) +{ + (void) cellHandle; + (void) pSerialNumber; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecGetRootOfTrustUid(uDeviceHandle_t cellHandle, + char *pRootOfTrustUid) +{ + (void) cellHandle; + (void) pRootOfTrustUid; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecC2cPair(uDeviceHandle_t cellHandle, + const char *pTESecret, + char *pKey, char *pHMac) +{ + (void) cellHandle; + (void) pTESecret; + (void) pKey; + (void) pHMac; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecC2cOpen(uDeviceHandle_t cellHandle, + const char *pTESecret, + const char *pKey, + const char *pHMacKey) +{ + (void) cellHandle; + (void) pTESecret; + (void) pKey; + (void) pHMacKey; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecC2cClose(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecSealSet(uDeviceHandle_t cellHandle, + const char *pDeviceProfileUid, + const char *pDeviceSerialNumberStr, + bool (*pKeepGoingCallback) (void)) +{ + (void) cellHandle; + (void) pDeviceProfileUid; + (void) pDeviceSerialNumberStr; + (void) pKeepGoingCallback; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK bool uCellSecIsSealed(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return false; +} + +U_WEAK int32_t uCellSecZtpGetDeviceCertificate(uDeviceHandle_t cellHandle, + char *pData, + size_t dataSizeBytes) +{ + (void) cellHandle; + (void) pData; + (void) dataSizeBytes; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecZtpGetPrivateKey(uDeviceHandle_t cellHandle, + char *pData, + size_t dataSizeBytes) +{ + (void) cellHandle; + (void) pData; + (void) dataSizeBytes; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecZtpGetCertificateAuthorities(uDeviceHandle_t cellHandle, + char *pData, + size_t dataSizeBytes) +{ + (void) cellHandle; + (void) pData; + (void) dataSizeBytes; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecE2eSetVersion(uDeviceHandle_t cellHandle, int32_t version) +{ + (void) cellHandle; + (void) version; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecE2eGetVersion(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecE2eEncrypt(uDeviceHandle_t cellHandle, + const void *pDataIn, + void *pDataOut, + size_t dataSizeBytes) +{ + (void) cellHandle; + (void) pDataIn; + (void) pDataOut; + (void) dataSizeBytes; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecPskGenerate(uDeviceHandle_t cellHandle, + size_t pskSizeBytes, char *pPsk, + char *pPskId) +{ + (void) cellHandle; + (void) pskSizeBytes; + (void) pPsk; + (void) pPskId; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecHeartbeatTrigger(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +// End of file diff --git a/common/security/src/u_security_stub_short_range.c b/common/security/src/u_security_stub_short_range.c new file mode 100644 index 00000000..c5d09a6b --- /dev/null +++ b/common/security/src/u_security_stub_short_range.c @@ -0,0 +1,56 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the Security API to be compiled without short range; + * if you call a short range API function from the source code here you must + * also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when short range is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" +#include "u_security.h" +#include "u_short_range.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uShortRangeGetSerialNumber(uDeviceHandle_t devHandle, + char *pSerialNumber) +{ + (void) devHandle; + (void) pSerialNumber; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +// End of file diff --git a/common/security/src/u_security_tls_stub_cell.c b/common/security/src/u_security_tls_stub_cell.c new file mode 100644 index 00000000..881159a5 --- /dev/null +++ b/common/security/src/u_security_tls_stub_cell.c @@ -0,0 +1,147 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the TLS Security API to be compiled without + * cellular; if you call a cellular API function from the source code + * here you must also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when cellular is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" +#include "u_security_tls.h" +#include "u_cell_sec_tls.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK uCellSecTlsContext_t *pUCellSecSecTlsAdd(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return NULL; +} + +U_WEAK void uCellSecTlsRemove(uCellSecTlsContext_t *pContext) +{ + (void) pContext; +} + +U_WEAK int32_t uCellSecTlsResetLastError() +{ + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecTlsRootCaCertificateNameSet(const uCellSecTlsContext_t *pContext, + const char *pName) +{ + (void) pContext; + (void) pName; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecTlsClientCertificateNameSet(const uCellSecTlsContext_t *pContext, + const char *pName) +{ + (void) pContext; + (void) pName; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecTlsClientPrivateKeyNameSet(const uCellSecTlsContext_t *pContext, + const char *pName, + const char *pPassword) +{ + (void) pContext; + (void) pName; + (void) pPassword; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecTlsClientPskSet(const uCellSecTlsContext_t *pContext, + const char *pPsk, size_t pskLengthBytes, + const char *pPskId, size_t pskIdLengthBytes, + bool generate) +{ + (void) pContext; + (void) pPsk; + (void) pskLengthBytes; + (void) pPskId; + (void) pskIdLengthBytes; + (void) generate; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecTlsUseDeviceCertificateSet(const uCellSecTlsContext_t *pContext, + bool includeCaCertificates) +{ + (void) pContext; + (void) includeCaCertificates; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecTlsCipherSuiteAdd(const uCellSecTlsContext_t *pContext, + int32_t ianaNumber) +{ + (void) pContext; + (void) ianaNumber; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecTlsVersionSet(const uCellSecTlsContext_t *pContext, + int32_t tlsVersionMin) +{ + (void) pContext; + (void) tlsVersionMin; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecTlsCertificateCheckSet(const uCellSecTlsContext_t *pContext, + uCellSecTlsCertficateCheck_t check, + const char *pUrl) +{ + (void) pContext; + (void) check; + (void) pUrl; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + +U_WEAK int32_t uCellSecTlsSniSet(const uCellSecTlsContext_t *pContext, + const char *pSni) +{ + (void) pContext; + (void) pSni; + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} + + +// End of file diff --git a/common/security/src/u_security_tls_stub_short_range.c b/common/security/src/u_security_tls_stub_short_range.c new file mode 100644 index 00000000..a84bb91a --- /dev/null +++ b/common/security/src/u_security_tls_stub_short_range.c @@ -0,0 +1,71 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the TLS Security API to be compiled without + * Wi-Fi; if you call a Wi-Fi API function from the source code here you + * must also include a weak stub for it which will return + * #U_ERROR_COMMON_NOT_SUPPORTED when Wi-Fi is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" +#include "u_security_tls.h" +#include "u_short_range_sec_tls.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK uShortRangeSecTlsContext_t *pUShortRangeSecTlsAdd(uSecurityTlsVersion_t tlsVersionMin, + const char *pRootCaCertificateName, + const char *pClientCertificateName, + const char *pClientPrivateKeyName, + bool certificateCheckOn) +{ + (void) tlsVersionMin; + (void) pRootCaCertificateName; + (void) pClientCertificateName; + (void) pClientPrivateKeyName; + (void) certificateCheckOn; + return NULL; +} + +U_WEAK void uShortRangeSecTlsRemove(uShortRangeSecTlsContext_t *pContext) +{ + (void) pContext; +} + +U_WEAK int32_t uShortRangeSecTlsResetLastError() +{ + return (int32_t) U_ERROR_COMMON_NOT_SUPPORTED; +} +// End of file diff --git a/common/short_range/api/u_short_range_sec_tls.h b/common/short_range/api/u_short_range_sec_tls.h index c0cc928c..19c4ade9 100644 --- a/common/short_range/api/u_short_range_sec_tls.h +++ b/common/short_range/api/u_short_range_sec_tls.h @@ -58,6 +58,18 @@ typedef struct { bool certificateCheckOn; } uShortRangeSecTlsContext_t; +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uShortRangeSecTlsPrivateLink(void); + /* ---------------------------------------------------------------- * FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/short_range/src/u_short_range.c b/common/short_range/src/u_short_range.c index c7661a5b..654189e8 100644 --- a/common/short_range/src/u_short_range.c +++ b/common/short_range/src/u_short_range.c @@ -55,6 +55,12 @@ #include "u_short_range_private.h" #include "u_short_range_edm_stream.h" +// The headers below necessary to work around an Espressif linker problem, see uShortRangeInit() +#include "u_device_private_short_range.h" +#include "u_security_tls.h" +#include "u_security_credential.h" +#include "u_short_range_sec_tls.h" // For uShortRangeSecTlsPrivateLink() + /* ---------------------------------------------------------------- * COMPILE-TIME MACROS * -------------------------------------------------------------- */ @@ -683,6 +689,17 @@ int32_t uShortRangeInit() { int32_t errorCode = (int32_t) U_ERROR_COMMON_SUCCESS; + // Workaround for Espressif linker missing out files that + // only contain functions which also have weak alternatives + // (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899) + // Basically any file that might end up containing only functions + // that also have WEAK linked counterparts will be lost, so we need + // to add a dummy function in those files and call it from somewhere + // that will always be present in the build, which for Short Range is + // here + uDevicePrivateShortRangeLink(); + uShortRangeSecTlsPrivateLink(); + if (gUShortRangePrivateMutex == NULL) { // Create the mutex that protects the linked list errorCode = uPortMutexCreate(&gUShortRangePrivateMutex); diff --git a/common/short_range/src/u_short_range_sec_tls.c b/common/short_range/src/u_short_range_sec_tls.c index 04df0423..a7b004f8 100644 --- a/common/short_range/src/u_short_range_sec_tls.c +++ b/common/short_range/src/u_short_range_sec_tls.c @@ -88,6 +88,15 @@ static uErrorCode_t storeString(const char *pSrc, char **ppDest) return errorCode; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uShortRangeSecTlsPrivateLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/common/sock/src/u_sock.c b/common/sock/src/u_sock.c index e47ec1cc..489a47e9 100644 --- a/common/sock/src/u_sock.c +++ b/common/sock/src/u_sock.c @@ -453,6 +453,7 @@ static int32_t init() { int32_t errorCode = (int32_t) U_ERROR_COMMON_SUCCESS; int32_t errnoLocal = U_SOCK_ENOMEM; + int32_t errnoLocalCell; uSockContainer_t **ppContainer = &gpContainerListHead; uSockContainer_t *pTmp = NULL; uSockContainer_t **ppPreviousNext = NULL; @@ -469,10 +470,17 @@ static int32_t init() errnoLocal = U_SOCK_ENONE; if (!gInitialised) { // uXxxSockInit returns a negated value of errno - // from the U_SOCK_Exxx list - errnoLocal = uCellSockInit(); - if (errnoLocal == U_SOCK_ENONE) { + // from the U_SOCK_Exxx list; one of cellular or + // wifi may return -U_SOCK_ENOSYS and that's OK, + // just means they've been compiled out + errnoLocalCell = uCellSockInit(); + if ((errnoLocalCell == U_SOCK_ENONE) || (errnoLocalCell == -U_SOCK_ENOSYS)) { errnoLocal = uWifiSockInit(); + if (errnoLocal == -U_SOCK_ENOSYS) { + errnoLocal = errnoLocalCell; + } + } else { + errnoLocal = errnoLocalCell; } if (errnoLocal == U_SOCK_ENONE) { @@ -493,6 +501,10 @@ static int32_t init() } gInitialised = true; + } else { + // Clean up on error + uCellSockDeinit(); + uWifiSockDeinit(); } } } diff --git a/common/sock/src/u_sock_stub_cell.c b/common/sock/src/u_sock_stub_cell.c new file mode 100644 index 00000000..a65f6451 --- /dev/null +++ b/common/sock/src/u_sock_stub_cell.c @@ -0,0 +1,247 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the sockets API to be compiled without cellular; + * if you call a cellular API function from the source code here you must + * also include a weak stub for it which will return + * minus #U_SOCK_ENOSYS when cellular is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" +#include "u_sock_errno.h" +#include "u_sock.h" +#include "u_cell_sock.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uCellSockInit() +{ + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockInitInstance(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; + return -U_SOCK_ENOSYS; +} + +U_WEAK void uCellSockDeinit() +{ +} + +U_WEAK int32_t uCellSockCreate(uDeviceHandle_t cellHandle, + uSockType_t type, + uSockProtocol_t protocol) +{ + (void) cellHandle; + (void) type; + (void) protocol; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockConnect(uDeviceHandle_t cellHandle, + int32_t sockHandle, + const uSockAddress_t *pRemoteAddress) +{ + (void) cellHandle; + (void) sockHandle; + (void) pRemoteAddress; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockClose(uDeviceHandle_t cellHandle, + int32_t sockHandle, + void (*pCallback) (uDeviceHandle_t, + int32_t)) +{ + (void) cellHandle; + (void) sockHandle; + (void) pCallback; + return -U_SOCK_ENOSYS; +} + +U_WEAK void uCellSockCleanup(uDeviceHandle_t cellHandle) +{ + (void) cellHandle; +} + +U_WEAK void uCellSockBlockingSet(uDeviceHandle_t cellHandle, + int32_t sockHandle, + bool isBlocking) +{ + (void) cellHandle; + (void) sockHandle; + (void) isBlocking; +} + +U_WEAK int32_t uCellSockOptionSet(uDeviceHandle_t cellHandle, + int32_t sockHandle, + int32_t level, + uint32_t option, + const void *pOptionValue, + size_t optionValueLength) +{ + (void) cellHandle; + (void) sockHandle; + (void) level; + (void) option; + (void) pOptionValue; + (void) optionValueLength; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockOptionGet(uDeviceHandle_t cellHandle, + int32_t sockHandle, + int32_t level, + uint32_t option, + void *pOptionValue, + size_t *pOptionValueLength) +{ + (void) cellHandle; + (void) sockHandle; + (void) level; + (void) option; + (void) pOptionValue; + (void) pOptionValueLength; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockSecure(uDeviceHandle_t cellHandle, + int32_t sockHandle, + int32_t profileId) +{ + (void) cellHandle; + (void) sockHandle; + (void) profileId; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockSetNextLocalPort(uDeviceHandle_t cellHandle, + int32_t port) +{ + (void) cellHandle; + (void) port; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockSendTo(uDeviceHandle_t cellHandle, + int32_t sockHandle, + const uSockAddress_t *pRemoteAddress, + const void *pData, size_t dataSizeBytes) +{ + (void) cellHandle; + (void) sockHandle; + (void) pRemoteAddress; + (void) pData; + (void) dataSizeBytes; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockReceiveFrom(uDeviceHandle_t cellHandle, + int32_t sockHandle, + uSockAddress_t *pRemoteAddress, + void *pData, size_t dataSizeBytes) +{ + (void) cellHandle; + (void) sockHandle; + (void) pRemoteAddress; + (void) pData; + (void) dataSizeBytes; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockWrite(uDeviceHandle_t cellHandle, + int32_t sockHandle, + const void *pData, size_t dataSizeBytes) +{ + (void) cellHandle; + (void) sockHandle; + (void) pData; + (void) dataSizeBytes; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockRead(uDeviceHandle_t cellHandle, + int32_t sockHandle, + void *pData, size_t dataSizeBytes) +{ + (void) cellHandle; + (void) sockHandle; + (void) pData; + (void) dataSizeBytes; + return -U_SOCK_ENOSYS; +} + +U_WEAK void uCellSockRegisterCallbackData(uDeviceHandle_t cellHandle, + int32_t sockHandle, + void (*pCallback) (uDeviceHandle_t, + int32_t)) +{ + (void) cellHandle; + (void) sockHandle; + (void) pCallback; +} + +U_WEAK void uCellSockRegisterCallbackClosed(uDeviceHandle_t cellHandle, + int32_t sockHandle, + void (*pCallback) (uDeviceHandle_t, + int32_t)) +{ + (void) cellHandle; + (void) sockHandle; + (void) pCallback; +} + +U_WEAK int32_t uCellSockGetHostByName(uDeviceHandle_t cellHandle, + const char *pHostName, + uSockIpAddress_t *pHostIpAddress) +{ + (void) cellHandle; + (void) pHostName; + (void) pHostIpAddress; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uCellSockGetLocalAddress(uDeviceHandle_t cellHandle, + int32_t sockHandle, + uSockAddress_t *pLocalAddress) +{ + (void) cellHandle; + (void) sockHandle; + (void) pLocalAddress; + return -U_SOCK_ENOSYS; +} + +// End of file diff --git a/common/sock/src/u_sock_stub_wifi.c b/common/sock/src/u_sock_stub_wifi.c new file mode 100644 index 00000000..a9049e66 --- /dev/null +++ b/common/sock/src/u_sock_stub_wifi.c @@ -0,0 +1,242 @@ +/* + * Copyright 2019-2022 u-blox + * + * 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. + */ + +/* Only #includes of u_* and the C standard library are allowed here, + * no platform stuff and no OS stuff. Anything required from + * the platform/OS must be brought in through u_port* to maintain + * portability. + */ + +/** @file + * @brief Stubs to allow the sockets API to be compiled without Wi-Fi; + * if you call a Wi-Fi API function from the source code here you must + * also include a weak stub for it which will return + * minus #U_SOCK_ENOSYS when Wi-Fi is not included in the build. + */ + +#ifdef U_CFG_OVERRIDE +# include "u_cfg_override.h" // For a customer's configuration override +#endif + +#include "stddef.h" // NULL, size_t etc. +#include "stdint.h" // int32_t etc. +#include "stdbool.h" + +#include "u_compiler.h" // U_WEAK +#include "u_error_common.h" +#include "u_device.h" +#include "u_sock_errno.h" +#include "u_sock.h" +#include "u_wifi_sock.h" + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + +U_WEAK int32_t uWifiSockInit(void) +{ + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockInitInstance(uDeviceHandle_t devHandle) +{ + (void) devHandle; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockDeinitInstance(uDeviceHandle_t devHandle) +{ + (void) devHandle; + return -U_SOCK_ENOSYS; +} + +U_WEAK void uWifiSockDeinit() +{ +} + +U_WEAK int32_t uWifiSockCreate(uDeviceHandle_t devHandle, + uSockType_t type, + uSockProtocol_t protocol) +{ + (void) devHandle; + (void) type; + (void) protocol; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockConnect(uDeviceHandle_t devHandle, + int32_t sockHandle, + const uSockAddress_t *pRemoteAddress) +{ + (void) devHandle; + (void) sockHandle; + (void) pRemoteAddress; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockClose(uDeviceHandle_t devHandle, + int32_t sockHandle, + uWifiSockCallback_t pCallback) +{ + (void) devHandle; + (void) sockHandle; + (void) pCallback; + return -U_SOCK_ENOSYS; +} + +U_WEAK void uWifiSockCleanup(uDeviceHandle_t devHandle) +{ + (void) devHandle; +} + +U_WEAK void uWifiSockBlockingSet(uDeviceHandle_t devHandle, + int32_t sockHandle, + bool isBlocking) +{ + (void) devHandle; + (void) sockHandle; + (void) isBlocking; +} + +U_WEAK int32_t uWifiSockOptionSet(uDeviceHandle_t devHandle, + int32_t sockHandle, + int32_t level, + uint32_t option, + const void *pOptionValue, + size_t optionValueLength) +{ + (void) devHandle; + (void) sockHandle; + (void) level; + (void) option; + (void) pOptionValue; + (void) optionValueLength; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockOptionGet(uDeviceHandle_t devHandle, + int32_t sockHandle, + int32_t level, + uint32_t option, + void *pOptionValue, + size_t *pOptionValueLength) +{ + (void) devHandle; + (void) sockHandle; + (void) level; + (void) option; + (void) pOptionValue; + (void) pOptionValueLength; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockSetNextLocalPort(uDeviceHandle_t devHandle, int32_t port) +{ + (void) devHandle; + (void) port; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockWrite(uDeviceHandle_t devHandle, + int32_t sockHandle, + const void *pData, size_t dataSizeBytes) +{ + (void) devHandle; + (void) sockHandle; + (void) pData; + (void) dataSizeBytes; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockRead(uDeviceHandle_t devHandle, + int32_t sockHandle, + void *pData, size_t dataSizeBytes) +{ + (void) devHandle; + (void) sockHandle; + (void) pData; + (void) dataSizeBytes; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockSendTo(uDeviceHandle_t devHandle, + int32_t sockHandle, + const uSockAddress_t *pRemoteAddress, + const void *pData, + size_t dataSizeBytes) +{ + (void) devHandle; + (void) sockHandle; + (void) pRemoteAddress; + (void) pData; + (void) dataSizeBytes; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockReceiveFrom(uDeviceHandle_t devHandle, + int32_t sockHandle, + uSockAddress_t *pRemoteAddress, + void *pData, size_t dataSizeBytes) +{ + (void) devHandle; + (void) sockHandle; + (void) pRemoteAddress; + (void) pData; + (void) dataSizeBytes; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockRegisterCallbackData(uDeviceHandle_t devHandle, + int32_t sockHandle, + uWifiSockCallback_t pCallback) +{ + (void) devHandle; + (void) sockHandle; + (void) pCallback; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockRegisterCallbackClosed(uDeviceHandle_t devHandle, + int32_t sockHandle, + uWifiSockCallback_t pCallback) +{ + (void) devHandle; + (void) sockHandle; + (void) pCallback; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockGetHostByName(uDeviceHandle_t devHandle, + const char *pHostName, + uSockIpAddress_t *pHostIpAddress) +{ + (void) devHandle; + (void) pHostName; + (void) pHostIpAddress; + return -U_SOCK_ENOSYS; +} + +U_WEAK int32_t uWifiSockGetLocalAddress(uDeviceHandle_t devHandle, + int32_t sockHandle, + uSockAddress_t *pLocalAddress) +{ + (void) devHandle; + (void) sockHandle; + (void) pLocalAddress; + return -U_SOCK_ENOSYS; +} + +// End of file diff --git a/example/cell/lte_cfg/lte_cfg_main.c b/example/cell/lte_cfg/lte_cfg_main.c index 73212e3e..96ad5f1a 100644 --- a/example/cell/lte_cfg/lte_cfg_main.c +++ b/example/cell/lte_cfg/lte_cfg_main.c @@ -22,29 +22,31 @@ * instructions. */ +#ifdef U_CFG_TEST_CELL_MODULE_TYPE + // Bring in all of the ubxlib public header files -#include "ubxlib.h" +# include "ubxlib.h" // Bring in the application settings -#include "u_cfg_app_platform_specific.h" +# include "u_cfg_app_platform_specific.h" -#ifndef U_CFG_DISABLE_TEST_AUTOMATION +# ifndef U_CFG_DISABLE_TEST_AUTOMATION // This purely for internal u-blox testing -# include "u_cell_test_cfg.h" -# include "u_cfg_test_platform_specific.h" -#endif +# include "u_cell_test_cfg.h" +# include "u_cfg_test_platform_specific.h" +# endif /* ---------------------------------------------------------------- * COMPILE-TIME MACROS * -------------------------------------------------------------- */ -#ifndef MY_MNO_PROFILE +# ifndef MY_MNO_PROFILE // Replace U_CELL_TEST_CFG_MNO_PROFILE with the MNO profile number // you require: consult the u-blox AT command manual for your module // to find out the possible values; 100, for example, is "Europe", // 90 is "global". -# define MY_MNO_PROFILE U_CELL_TEST_CFG_MNO_PROFILE -#endif +# define MY_MNO_PROFILE U_CELL_TEST_CFG_MNO_PROFILE +# endif // The RATs you want the module to use, in priority order. // Set the value of MY_RAT0 to the RAT you want to use @@ -60,15 +62,15 @@ // it supports at the same time), add secondary and tertiary // RATs by setting the values for MY_RAT1 and MY_RAT2 as // required. -#ifndef MY_RAT0 -# define MY_RAT0 U_CELL_NET_RAT_UNKNOWN_OR_NOT_USED -#endif -#ifndef MY_RAT1 -# define MY_RAT1 U_CELL_NET_RAT_UNKNOWN_OR_NOT_USED -#endif -#ifndef MY_RAT2 -# define MY_RAT2 U_CELL_NET_RAT_UNKNOWN_OR_NOT_USED -#endif +# ifndef MY_RAT0 +# define MY_RAT0 U_CELL_NET_RAT_UNKNOWN_OR_NOT_USED +# endif +# ifndef MY_RAT1 +# define MY_RAT1 U_CELL_NET_RAT_UNKNOWN_OR_NOT_USED +# endif +# ifndef MY_RAT2 +# define MY_RAT2 U_CELL_NET_RAT_UNKNOWN_OR_NOT_USED +# endif // Set the values of MY_xxx_BANDMASKx to your chosen band masks // for the Cat M1 and NB1 RATs; see cell/api/u_cell_cfg.h for some @@ -80,29 +82,29 @@ // so take care. // When in doubt, set an MNO profile and rely on that to configure // the bands that your modules _does_ support. -#ifndef MY_CATM1_BANDMASK1 -# define MY_CATM1_BANDMASK1 U_CELL_CFG_BAND_MASK_1_NORTH_AMERICA_CATM1_DEFAULT -#endif -#ifndef MY_CATM1_BANDMASK2 -# define MY_CATM1_BANDMASK2 U_CELL_CFG_BAND_MASK_2_NORTH_AMERICA_CATM1_DEFAULT -#endif -#ifndef MY_NB1_BANDMASK1 -# define MY_NB1_BANDMASK1 U_CELL_CFG_BAND_MASK_1_EUROPE_NB1_DEFAULT -#endif -#ifndef MY_NB1_BANDMASK2 -# define MY_NB1_BANDMASK2 U_CELL_CFG_BAND_MASK_2_EUROPE_NB1_DEFAULT -#endif +# ifndef MY_CATM1_BANDMASK1 +# define MY_CATM1_BANDMASK1 U_CELL_CFG_BAND_MASK_1_NORTH_AMERICA_CATM1_DEFAULT +# endif +# ifndef MY_CATM1_BANDMASK2 +# define MY_CATM1_BANDMASK2 U_CELL_CFG_BAND_MASK_2_NORTH_AMERICA_CATM1_DEFAULT +# endif +# ifndef MY_NB1_BANDMASK1 +# define MY_NB1_BANDMASK1 U_CELL_CFG_BAND_MASK_1_EUROPE_NB1_DEFAULT +# endif +# ifndef MY_NB1_BANDMASK2 +# define MY_NB1_BANDMASK2 U_CELL_CFG_BAND_MASK_2_EUROPE_NB1_DEFAULT +# endif // For u-blox internal testing only -#ifdef U_PORT_TEST_ASSERT -# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); -#else -# define EXAMPLE_FINAL_STATE(x) -#endif +# ifdef U_PORT_TEST_ASSERT +# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); +# else +# define EXAMPLE_FINAL_STATE(x) +# endif -#ifndef U_PORT_TEST_FUNCTION -# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. -#endif +# ifndef U_PORT_TEST_FUNCTION +# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. +# endif /* ---------------------------------------------------------------- * TYPES @@ -124,7 +126,6 @@ uCellNetRat_t gMyRatList[] = {MY_RAT0, MY_RAT1, MY_RAT2}; // for the module is likely different that from the MCU: check // the data sheet for the module to determine the mapping. -#ifdef U_CFG_TEST_CELL_MODULE_TYPE // DEVICE i.e. module/chip configuration: in this case a cellular // module connected via UART static const uDeviceCfg_t gDeviceCfg = { @@ -168,10 +169,6 @@ static const uNetworkCfgCell_t gNetworkCfg = { // will be aborted, allowing you immediate control. If this // field is set, timeoutSeconds will be ignored. }; -#else -static const uDeviceCfg_t gDeviceCfg = {.deviceType = U_DEVICE_TYPE_NONE}; -static const uNetworkCfgCell_t gNetworkCfg = {.type = U_NETWORK_TYPE_NONE}; -#endif // The names for each RAT, for debug purposes static const char *const gpRatStr[] = {"unknown or not used", @@ -440,11 +437,11 @@ U_PORT_TEST_FUNCTION("[example]", "exampleCellLteCfg") uPortLog("### Done.\n"); -#ifdef U_CFG_TEST_CELL_MODULE_TYPE // For u-blox internal testing only EXAMPLE_FINAL_STATE((address.ipAddress.type == U_SOCK_ADDRESS_TYPE_V4) || (address.ipAddress.type == U_SOCK_ADDRESS_TYPE_V6)); -#endif } +#endif // #ifdef U_CFG_TEST_CELL_MODULE_TYPE + // End of file diff --git a/example/cell/power_saving/cell_power_saving_3gpp_main.c b/example/cell/power_saving/cell_power_saving_3gpp_main.c index 5501b41a..e8e7b822 100644 --- a/example/cell/power_saving/cell_power_saving_3gpp_main.c +++ b/example/cell/power_saving/cell_power_saving_3gpp_main.c @@ -22,17 +22,19 @@ * instructions. */ +#ifdef U_CFG_TEST_CELL_MODULE_TYPE + // Bring in all of the ubxlib public header files -#include "ubxlib.h" +# include "ubxlib.h" // Bring in the application settings -#include "u_cfg_app_platform_specific.h" +# include "u_cfg_app_platform_specific.h" -#ifndef U_CFG_DISABLE_TEST_AUTOMATION +# ifndef U_CFG_DISABLE_TEST_AUTOMATION // This purely for internal u-blox testing -# include "u_cell_test_cfg.h" -# include "u_cfg_test_platform_specific.h" -#endif +# include "u_cell_test_cfg.h" +# include "u_cfg_test_platform_specific.h" +# endif /* ---------------------------------------------------------------- * COMPILE-TIME MACROS @@ -40,18 +42,18 @@ // The requested "active time" for 3GPP power saving. This is the // period of inactivity after which the module may enter deep sleep. -#ifndef ACTIVE_TIME_SECONDS -# define ACTIVE_TIME_SECONDS 60 -#endif +# ifndef ACTIVE_TIME_SECONDS +# define ACTIVE_TIME_SECONDS 60 +# endif // The requested period at which the module will wake up to inform // the cellular network that it is still connected; this should // be set to around 1.5 times your application's natural periodicity, // as a safety-net; the wake-up only occurs if the module has not already // woken up for other reasons in time. -#ifndef PERIODIC_WAKEUP_SECONDS -# define PERIODIC_WAKEUP_SECONDS (3600 * 4) -#endif +# ifndef PERIODIC_WAKEUP_SECONDS +# define PERIODIC_WAKEUP_SECONDS (3600 * 4) +# endif // The RAT the module will use. While it is not a requirement // to set this explicitly (you could, for instance just register @@ -61,20 +63,20 @@ // require a re-boot to apply new 3GPP power saving settings, so // rather than messing about registering and then rebooting if // required, for this example code we set the RAT explicitly. -#ifndef MY_RAT -# define MY_RAT U_CELL_NET_RAT_CATM1 -#endif +# ifndef MY_RAT +# define MY_RAT U_CELL_NET_RAT_CATM1 +# endif // For u-blox internal testing only -#ifdef U_PORT_TEST_ASSERT -# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); -#else -# define EXAMPLE_FINAL_STATE(x) -#endif +# ifdef U_PORT_TEST_ASSERT +# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); +# else +# define EXAMPLE_FINAL_STATE(x) +# endif -#ifndef U_PORT_TEST_FUNCTION -# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. -#endif +# ifndef U_PORT_TEST_FUNCTION +# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. +# endif /* ---------------------------------------------------------------- * TYPES @@ -93,7 +95,6 @@ // for the module is likely different that from the MCU: check // the data sheet for the module to determine the mapping. -#ifdef U_CFG_TEST_CELL_MODULE_TYPE // DEVICE i.e. module/chip configuration: in this case a cellular // module connected via UART static const uDeviceCfg_t gDeviceCfg = { @@ -137,10 +138,6 @@ static const uNetworkCfgCell_t gNetworkCfg = { // will be aborted, allowing you immediate control. If this // field is set, timeoutSeconds will be ignored. }; -#else -static const uDeviceCfg_t gDeviceCfg = {.deviceType = U_DEVICE_TYPE_NONE}; -static const uNetworkCfgCell_t gNetworkCfg = {.type = U_NETWORK_TYPE_NONE}; -#endif // Flag that allows us to check if power saving has been set. static volatile bool g3gppPowerSavingSet = false; @@ -263,10 +260,10 @@ U_PORT_TEST_FUNCTION("[example]", "exampleCellPowerSaving3gpp") uPortLog("### Done.\n"); -#if defined(U_CFG_TEST_CELL_MODULE_TYPE) && !defined(U_CFG_CELL_DISABLE_UART_POWER_SAVING) +# ifndef U_CFG_CELL_DISABLE_UART_POWER_SAVING // For u-blox internal testing only EXAMPLE_FINAL_STATE((x < 0) || g3gppPowerSavingSet); -# ifdef U_PORT_TEST_ASSERT +# ifdef U_PORT_TEST_ASSERT // We don't want 3GPP power saving left on for our internal testing, // we need the module to stay awake, so switch it off again here if (g3gppPowerSavingSet) { @@ -281,14 +278,15 @@ U_PORT_TEST_FUNCTION("[example]", "exampleCellPowerSaving3gpp") } // Close the device // Note: we don't power the device down here in order - // to speed up testing; you may prefer to power it off - // by setting the second parameter to true. + // to speed up testing. uDeviceClose(devHandle, false); uDeviceDeinit(); uPortDeinit(); } +# endif # endif -#endif } +#endif // #ifdef U_CFG_TEST_CELL_MODULE_TYPE + // End of file diff --git a/example/cell/power_saving/cell_power_saving_e_drx_main.c b/example/cell/power_saving/cell_power_saving_e_drx_main.c index 61669be9..351af3df 100644 --- a/example/cell/power_saving/cell_power_saving_e_drx_main.c +++ b/example/cell/power_saving/cell_power_saving_e_drx_main.c @@ -22,17 +22,19 @@ * instructions. */ +#ifdef U_CFG_TEST_CELL_MODULE_TYPE + // Bring in all of the ubxlib public header files -#include "ubxlib.h" +# include "ubxlib.h" // Bring in the application settings -#include "u_cfg_app_platform_specific.h" +# include "u_cfg_app_platform_specific.h" -#ifndef U_CFG_DISABLE_TEST_AUTOMATION +# ifndef U_CFG_DISABLE_TEST_AUTOMATION // This purely for internal u-blox testing -# include "u_cell_test_cfg.h" -# include "u_cfg_test_platform_specific.h" -#endif +# include "u_cell_test_cfg.h" +# include "u_cfg_test_platform_specific.h" +# endif /* ---------------------------------------------------------------- * COMPILE-TIME MACROS @@ -41,9 +43,9 @@ // The requested E-DRX time; the module will sleep for this many, // seconds, wake-up to listen for messages, then return to sleep, // etc., switching its radio off in the sleep period to save power. -#ifndef EDRX_SECONDS -# define EDRX_SECONDS 10 -#endif +# ifndef EDRX_SECONDS +# define EDRX_SECONDS 10 +# endif // The RAT the module will use. While it is not a requirement // to set this explicitly (you could, for instance just register @@ -53,20 +55,20 @@ // require a re-boot to apply new E-DRX settings, so rather than // messing about registering and then rebooting if required, // for this example code we set the RAT explicitly. -#ifndef MY_RAT -# define MY_RAT U_CELL_NET_RAT_CATM1 -#endif +# ifndef MY_RAT +# define MY_RAT U_CELL_NET_RAT_CATM1 +# endif // For u-blox internal testing only -#ifdef U_PORT_TEST_ASSERT -# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); -#else -# define EXAMPLE_FINAL_STATE(x) -#endif +# ifdef U_PORT_TEST_ASSERT +# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); +# else +# define EXAMPLE_FINAL_STATE(x) +# endif -#ifndef U_PORT_TEST_FUNCTION -# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. -#endif +# ifndef U_PORT_TEST_FUNCTION +# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. +# endif /* ---------------------------------------------------------------- * TYPES @@ -85,7 +87,6 @@ // for the module is likely different that from the MCU: check // the data sheet for the module to determine the mapping. -#ifdef U_CFG_TEST_CELL_MODULE_TYPE // DEVICE i.e. module/chip configuration: in this case a cellular // module connected via UART static const uDeviceCfg_t gDeviceCfg = { @@ -129,10 +130,6 @@ static const uNetworkCfgCell_t gNetworkCfg = { // will be aborted, allowing you immediate control. If this // field is set, timeoutSeconds will be ignored. }; -#else -static const uDeviceCfg_t gDeviceCfg = {.deviceType = U_DEVICE_TYPE_NONE}; -static const uNetworkCfgCell_t gNetworkCfg = {.type = U_NETWORK_TYPE_NONE}; -#endif // Flag that allows us to check if E-DRX has been set. static volatile bool gEDrxSet = false; @@ -258,10 +255,10 @@ U_PORT_TEST_FUNCTION("[example]", "exampleCellPowerSavingEDrx") uPortLog("### Done.\n"); -#if defined(U_CFG_TEST_CELL_MODULE_TYPE) && !defined(U_CFG_CELL_DISABLE_UART_POWER_SAVING) +# ifndef U_CFG_CELL_DISABLE_UART_POWER_SAVING // For u-blox internal testing only EXAMPLE_FINAL_STATE((x < 0) || gEDrxSet); -# ifdef U_PORT_TEST_ASSERT +# ifdef U_PORT_TEST_ASSERT // We don't want E-DRX on for our internal testing, so // switch it off again here if (gEDrxSet) { @@ -276,14 +273,15 @@ U_PORT_TEST_FUNCTION("[example]", "exampleCellPowerSavingEDrx") } // Close the device // Note: we don't power the device down here in order - // to speed up testing; you may prefer to power it off - // by setting the second parameter to true. + // to speed up testing. uDeviceClose(devHandle, false); uDeviceDeinit(); uPortDeinit(); } +# endif # endif -#endif } +#endif // #ifdef U_CFG_TEST_CELL_MODULE_TYPE + // End of file diff --git a/example/gnss/cfg_val_main.c b/example/gnss/cfg_val_main.c index efa17780..b46975a9 100644 --- a/example/gnss/cfg_val_main.c +++ b/example/gnss/cfg_val_main.c @@ -22,31 +22,33 @@ * instructions. */ +#ifdef U_CFG_TEST_GNSS_MODULE_TYPE + // Bring in all of the ubxlib public header files -#include "ubxlib.h" +# include "ubxlib.h" // Bring in the application settings -#include "u_cfg_app_platform_specific.h" +# include "u_cfg_app_platform_specific.h" -#ifndef U_CFG_DISABLE_TEST_AUTOMATION +# ifndef U_CFG_DISABLE_TEST_AUTOMATION // This purely for internal u-blox testing -# include "u_cfg_test_platform_specific.h" -#endif +# include "u_cfg_test_platform_specific.h" +# endif /* ---------------------------------------------------------------- * COMPILE-TIME MACROS * -------------------------------------------------------------- */ // For u-blox internal testing only -#ifdef U_PORT_TEST_ASSERT -# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); -#else -# define EXAMPLE_FINAL_STATE(x) -#endif +# ifdef U_PORT_TEST_ASSERT +# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); +# else +# define EXAMPLE_FINAL_STATE(x) +# endif -#ifndef U_PORT_TEST_FUNCTION -# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. -#endif +# ifndef U_PORT_TEST_FUNCTION +# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. +# endif /* ---------------------------------------------------------------- * TYPES @@ -67,7 +69,7 @@ // for the module is likely different that from the MCU: check // the data sheet for the module to determine the mapping. -#if defined(U_CFG_TEST_GNSS_MODULE_TYPE) && ((U_CFG_APP_GNSS_UART >= 0) || (U_CFG_APP_GNSS_I2C >= 0) || (U_CFG_APP_GNSS_SPI >= 0)) +#if ((U_CFG_APP_GNSS_UART >= 0) || (U_CFG_APP_GNSS_I2C >= 0) || (U_CFG_APP_GNSS_SPI >= 0)) // DEVICE i.e. module/chip configuration: in this case a GNSS // module connected via UART or I2C or SPI static const uDeviceCfg_t gDeviceCfg = { @@ -89,7 +91,7 @@ static const uDeviceCfg_t gDeviceCfg = { // .i2cAddress = 0x43 }, }, -# if (U_CFG_APP_GNSS_I2C >= 0) +# if (U_CFG_APP_GNSS_I2C >= 0) .transportType = U_DEVICE_TRANSPORT_TYPE_I2C, .transportCfg = { .cfgI2c = { @@ -130,7 +132,7 @@ static const uDeviceCfg_t gDeviceCfg = { .device = U_COMMON_SPI_CONTROLLER_DEVICE_DEFAULTS(U_CFG_APP_PIN_GNSS_SPI_SELECT) }, }, -# else +# else .transportType = U_DEVICE_TRANSPORT_TYPE_UART, .transportCfg = { .cfgUart = { @@ -142,11 +144,11 @@ static const uDeviceCfg_t gDeviceCfg = { .pinRts = U_CFG_APP_PIN_GNSS_RTS }, }, -# endif +# endif }; -#else +# else static const uDeviceCfg_t gDeviceCfg = {.deviceType = U_DEVICE_TYPE_NONE}; -#endif +# endif /* ---------------------------------------------------------------- * STATIC FUNCTIONS @@ -309,11 +311,15 @@ U_PORT_TEST_FUNCTION("[example]", "exampleGnssCfgVal") uPortLog("Done.\n"); +# if ((U_CFG_APP_GNSS_UART >= 0) || (U_CFG_APP_GNSS_I2C >= 0)) // For u-blox internal testing only EXAMPLE_FINAL_STATE((numValues > 0) && (returnCode == 0) && boolValue); +# endif } else { uPortLog("The GEOFENCE fields of the CFGVALXXX API are only supported on M9 modules.\n"); } } +#endif // #ifdef U_CFG_TEST_GNSS_MODULE_TYPE + // End of file diff --git a/example/gnss/msg_main.c b/example/gnss/msg_main.c index 871091bf..9401981a 100644 --- a/example/gnss/msg_main.c +++ b/example/gnss/msg_main.c @@ -24,16 +24,18 @@ * instructions. */ +#ifdef U_CFG_TEST_GNSS_MODULE_TYPE + // Bring in all of the ubxlib public header files -#include "ubxlib.h" +# include "ubxlib.h" // Bring in the application settings -#include "u_cfg_app_platform_specific.h" +# include "u_cfg_app_platform_specific.h" -#ifndef U_CFG_DISABLE_TEST_AUTOMATION +# ifndef U_CFG_DISABLE_TEST_AUTOMATION // This purely for internal u-blox testing -# include "u_cfg_test_platform_specific.h" -#endif +# include "u_cfg_test_platform_specific.h" +# endif /* ---------------------------------------------------------------- * COMPILE-TIME MACROS @@ -43,18 +45,18 @@ * message, which has a body of length 92 bytes, and any NMEA message, * which have a maximum size of 82 bytes. */ -#define MY_MESSAGE_BUFFER_LENGTH (92 + U_UBX_PROTOCOL_OVERHEAD_LENGTH_BYTES) +# define MY_MESSAGE_BUFFER_LENGTH (92 + U_UBX_PROTOCOL_OVERHEAD_LENGTH_BYTES) // For u-blox internal testing only -#ifdef U_PORT_TEST_ASSERT -# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); -#else -# define EXAMPLE_FINAL_STATE(x) -#endif +# ifdef U_PORT_TEST_ASSERT +# define EXAMPLE_FINAL_STATE(x) U_PORT_TEST_ASSERT(x); +# else +# define EXAMPLE_FINAL_STATE(x) +# endif -#ifndef U_PORT_TEST_FUNCTION -# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. -#endif +# ifndef U_PORT_TEST_FUNCTION +# error if you are not using the unit test framework to run this code you must ensure that the platform clocks/RTOS are set up and either define U_PORT_TEST_FUNCTION yourself or replace it as necessary. +# endif /* ---------------------------------------------------------------- * TYPES @@ -73,7 +75,7 @@ // for the module is likely different that from the MCU: check // the data sheet for the module to determine the mapping. -#if defined(U_CFG_TEST_GNSS_MODULE_TYPE) && ((U_CFG_APP_GNSS_UART >= 0) || (U_CFG_APP_GNSS_I2C >= 0) || (U_CFG_APP_GNSS_SPI >= 0)) +#if ((U_CFG_APP_GNSS_UART >= 0) || (U_CFG_APP_GNSS_I2C >= 0) || (U_CFG_APP_GNSS_SPI >= 0)) // DEVICE i.e. module/chip configuration: in this case a GNSS // module connected via UART or I2C or SPI static const uDeviceCfg_t gDeviceCfg = { @@ -95,7 +97,7 @@ static const uDeviceCfg_t gDeviceCfg = { // .i2cAddress = 0x43 }, }, -# if (U_CFG_APP_GNSS_I2C >= 0) +# if (U_CFG_APP_GNSS_I2C >= 0) .transportType = U_DEVICE_TRANSPORT_TYPE_I2C, .transportCfg = { .cfgI2c = { @@ -136,7 +138,7 @@ static const uDeviceCfg_t gDeviceCfg = { .device = U_COMMON_SPI_CONTROLLER_DEVICE_DEFAULTS(U_CFG_APP_PIN_GNSS_SPI_SELECT) }, }, -# else +# else .transportType = U_DEVICE_TRANSPORT_TYPE_UART, .transportCfg = { .cfgUart = { @@ -148,11 +150,11 @@ static const uDeviceCfg_t gDeviceCfg = { .pinRts = U_CFG_APP_PIN_GNSS_RTS }, }, -# endif +# endif }; -#else +# else static const uDeviceCfg_t gDeviceCfg = {.deviceType = U_DEVICE_TYPE_NONE}; -#endif +# endif // Count of messages received static size_t gMessageCount = 0; @@ -333,10 +335,12 @@ U_PORT_TEST_FUNCTION("[example]", "exampleGnssMsg") uPortFree(pBuffer); -#if defined(U_CFG_TEST_GNSS_MODULE_TYPE) && ((U_CFG_APP_GNSS_UART >= 0) || (U_CFG_APP_GNSS_I2C >= 0) || (U_CFG_APP_GNSS_SPI >= 0)) +#if ((U_CFG_APP_GNSS_UART >= 0) || (U_CFG_APP_GNSS_I2C >= 0) || (U_CFG_APP_GNSS_SPI >= 0)) // For u-blox internal testing only EXAMPLE_FINAL_STATE((length > 0) && (gMessageCount > 0) && (returnCode == 0)); -#endif +# endif } +#endif // #ifdef U_CFG_TEST_GNSS_MODULE_TYPE + // End of file diff --git a/gnss/api/u_gnss_pos.h b/gnss/api/u_gnss_pos.h index 1214e028..6f5033a1 100644 --- a/gnss/api/u_gnss_pos.h +++ b/gnss/api/u_gnss_pos.h @@ -71,6 +71,18 @@ extern "C" { * TYPES * -------------------------------------------------------------- */ +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uGnssPosPrivateLink(void); + /* ---------------------------------------------------------------- * FUNCTIONS * -------------------------------------------------------------- */ diff --git a/gnss/src/u_gnss.c b/gnss/src/u_gnss.c index 19fa5044..9aa8a54e 100644 --- a/gnss/src/u_gnss.c +++ b/gnss/src/u_gnss.c @@ -51,6 +51,13 @@ #include "u_gnss_msg.h" #include "u_gnss_private.h" +// The headers below are necessary to work around an Espressif linker problem, see uGnssInit() +#include "u_device_private_gnss.h" +#include "u_network.h" +#include "u_network_config_gnss.h" +#include "u_network_private_gnss.h" +#include "u_gnss_pos.h" // For uGnssPosPrivateLink() + /* ---------------------------------------------------------------- * COMPILE-TIME MACROS * -------------------------------------------------------------- */ @@ -188,6 +195,18 @@ int32_t uGnssInit() { int32_t errorCode = (int32_t) U_ERROR_COMMON_SUCCESS; + // Workaround for Espressif linker missing out files that + // only contain functions which also have weak alternatives + // (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899) + // Basically any file that might end up containing only functions + // that also have WEAK linked counterparts will be lost, so we need + // to add a dummy function in those files and call it from somewhere + // that will always be present in the build, which for GNSS we + // choose to be here + uDevicePrivateGnssLink(); + uNetworkPrivateGnssLink(); + uGnssPosPrivateLink(); + if (gUGnssPrivateMutex == NULL) { // Create the mutex that protects the linked list errorCode = uPortMutexCreate(&gUGnssPrivateMutex); diff --git a/gnss/src/u_gnss_pos.c b/gnss/src/u_gnss_pos.c index e72275de..ea6b9c74 100644 --- a/gnss/src/u_gnss_pos.c +++ b/gnss/src/u_gnss_pos.c @@ -279,6 +279,15 @@ static void posGetTask(void *pParameter) uPortTaskDelete(NULL); } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uGnssPosPrivateLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * -------------------------------------------------------------- */ diff --git a/gnss/test/u_gnss_test_private.c b/gnss/test/u_gnss_test_private.c index 53bf98ad..9dd64ec1 100644 --- a/gnss/test/u_gnss_test_private.c +++ b/gnss/test/u_gnss_test_private.c @@ -58,8 +58,8 @@ #ifdef U_CFG_TEST_CELL_MODULE_TYPE #include "u_cell.h" #include "u_cell_pwr.h" -#endif #include "u_cell_loc.h" // For uCellLocGnssInsideCell() +#endif #include "u_gnss_module_type.h" #include "u_gnss_type.h" @@ -428,8 +428,11 @@ int32_t uGnssTestPrivatePreamble(uGnssModuleType_t moduleType, U_CFG_APP_PIN_GNSS_ENABLE_POWER, false, &pParameters->gnssHandle); if (errorCode >= 0) { - if ((pParameters->cellHandle != NULL) && - !uCellLocGnssInsideCell(pParameters->cellHandle)) { + if ((pParameters->cellHandle != NULL) +#ifdef U_CFG_TEST_CELL_MODULE_TYPE + && !uCellLocGnssInsideCell(pParameters->cellHandle) +#endif + ) { // If we're talking via cellular and the GNSS chip // isn't inside the cellular module, need to configure the // module pins that control the GNSS chip @@ -467,6 +470,7 @@ void uGnssTestPrivatePostamble(uGnssTestPrivate_t *pParameters, pParameters->gnssHandle = NULL; if (pParameters->cellHandle != NULL) { +#ifdef U_CFG_TEST_CELL_MODULE_TYPE // Cellular was in use, call the cellular test postamble uCellTestPrivate_t parameters = U_CELL_TEST_PRIVATE_DEFAULTS; parameters.uartHandle = pParameters->streamHandle; @@ -474,6 +478,7 @@ void uGnssTestPrivatePostamble(uGnssTestPrivate_t *pParameters, parameters.cellHandle = pParameters->cellHandle; uCellTestPrivatePostamble(¶meters, powerOff); pParameters->cellHandle = NULL; +#endif } else { if (pParameters->streamHandle >= 0) { switch (pParameters->transportType) { @@ -509,6 +514,7 @@ void uGnssTestPrivateCleanup(uGnssTestPrivate_t *pParameters) pParameters->gnssHandle = NULL; if (pParameters->cellHandle != NULL) { +#ifdef U_CFG_TEST_CELL_MODULE_TYPE // Cellular was in use, call the cellular test clean-up uCellTestPrivate_t parameters = U_CELL_TEST_PRIVATE_DEFAULTS; parameters.uartHandle = pParameters->streamHandle; @@ -516,6 +522,7 @@ void uGnssTestPrivateCleanup(uGnssTestPrivate_t *pParameters) parameters.cellHandle = pParameters->cellHandle; uCellTestPrivateCleanup(¶meters); pParameters->cellHandle = NULL; +#endif } else { if (pParameters->streamHandle >= 0) { switch (pParameters->transportType) { diff --git a/port/README.md b/port/README.md index cd9b6aab..463191fb 100644 --- a/port/README.md +++ b/port/README.md @@ -41,8 +41,6 @@ Available features currently are: * `cell`: Include `cell` API * `gnss`: Include `gnss` API -**IMPORTANT:** This is under development so `short_range`, `cell` and `gnss` must currently always be enabled. - ## Example ```cmake set(UBXLIB_BASE ) diff --git a/port/platform/arduino/source.txt b/port/platform/arduino/source.txt index ca3e55d0..e4807784 100644 --- a/port/platform/arduino/source.txt +++ b/port/platform/arduino/source.txt @@ -46,23 +46,40 @@ common/device/src/u_device_serial.c common/device/src/u_device_shared.c common/device/src/u_device_private.c common/device/src/u_device_private_cell.c +common/device/src/u_device_private_cell_stub.c common/device/src/u_device_private_gnss.c +common/device/src/u_device_private_gnss_stub.c common/device/src/u_device_private_short_range.c +common/device/src/u_device_private_short_range_stub.c common/network/src/u_network.c common/network/src/u_network_shared.c common/network/src/u_network_private_ble_extmod.c common/network/src/u_network_private_ble_intmod.c common/network/src/u_network_private_cell.c +common/network/src/u_network_private_cell_stub.c common/network/src/u_network_private_wifi.c +common/network/src/u_network_private_wifi_stub.c common/network/src/u_network_private_gnss.c +common/network/src/u_network_private_gnss_stub.c common/sock/src/u_sock.c +common/sock/src/u_sock_stub_cell.c +common/sock/src/u_sock_stub_wifi.c common/security/src/u_security.c common/security/src/u_security_credential.c common/security/src/u_security_tls.c +common/security/src/u_security_stub_cell.c +common/security/src/u_security_stub_short_range.c +common/security/src/u_security_credential_stub_cell.c +common/security/src/u_security_credential_stub_short_range.c +common/security/src/u_security_tls_stub_cell.c +common/security/src/u_security_tls_stub_short_range.c common/location/src/u_location.c common/location/src/u_location_shared.c common/location/src/u_location_private_cloud_locate.c +common/location/src/u_location_stub_cell.c +common/location/src/u_location_stub_gnss.c common/at_client/src/u_at_client.c +common/at_client/src/u_at_client_stub_short_range.c common/ubx_protocol/src/u_ubx_protocol.c common/spartn/src/u_spartn.c common/spartn/src/u_spartn_crc.c @@ -78,7 +95,11 @@ common/utils/src/u_time.c common/utils/src/u_mempool.c common/utils/src/u_interface.c common/mqtt_client/src/u_mqtt_client.c +common/mqtt_client/src/u_mqtt_client_stub_cell.c +common/mqtt_client/src/u_mqtt_client_stub_wifi.c common/http_client/src/u_http_client.c +common/http_client/src/u_http_client_stub_cell.c +common/http_client/src/u_http_client_stub_wifi.c common/assert/src/u_assert.c port/u_port_heap.c port/platform/common/event_queue/u_port_event_queue.c diff --git a/port/platform/common/automation/DATABASE.md b/port/platform/common/automation/DATABASE.md index f81e4604..f9df23e2 100644 --- a/port/platform/common/automation/DATABASE.md +++ b/port/platform/common/automation/DATABASE.md @@ -20,7 +20,10 @@ The table below defines the instances of test hardware available on the `ubxlib` | 1 | Doxygen | 1 | | | | | | | | | 2 | AStyle style checker | 1 | | | | | | | | | 3 | Pylint | 2 | | | | | | | | -| 4 | Static size check | 2 | | | | | | | | +| 4.1 | Static size check | 2 | | | | | | | | +| 4.2 | Static size check, cell only | 2 | | | | | SARA_R5 | | UBXLIB_FEATURES=cell | +| 4.3 | Static size check, gnss only | 2 | | | | | M9 | | UBXLIB_FEATURES=gnss | +| 4.4 | Static size check, short range only | 2 | | | | | NINA_W15 | | UBXLIB_FEATURES=short_range | | 5 | No floating point check | 2 | | | | | | | | | 6.1 | CodeChecker (Zephyr) | | NRF5340 | nrf5340dk_nrf5340_cpuapp | CodeChecker:Zephyr | | SARA_R5 M8 NINA_W15 | | U_CFG_BLE_MODULE_INTERNAL U_BLE_TEST_CFG_REMOTE_SPS_CENTRAL=2462ABB6CC42p U_BLE_TEST_CFG_REMOTE_SPS_PERIPHERAL=2462ABB6EAC6p U_CFG_APP_SHORT_RANGE_ROLE=1 U_CFG_TEST_NET_STATUS_CELL U_CFG_TEST_NET_STATUS_SHORT_RANGE U_DEBUG_UTILS_DUMP_THREADS | | 6.2 | CodeChecker (STM32Cube) | | STM32F4 | | CodeChecker:STM32Cube || SARA_R5 NINA_W15 M8 | | U_CFG_APP_PIN_SHORT_RANGE_RESET_TO_DEFAULTS=0x42 U_CFG_SARA_R5_M8_WORKAROUND U_CFG_TEST_PIN_A=-1 U_CFG_TEST_PIN_B=-1 U_CFG_TEST_PIN_C=-1 U_CFG_TEST_UART_A=-1 U_BLE_TEST_CFG_REMOTE_SPS_CENTRAL=2462ABB6CC42p U_CFG_TEST_SECURITY_C2C_TE_SECRET=\x00\x01\x02\x03\x04\x05\x06\x07\xff\xfe\xfd\xfc\xfb\xfa\xf9\xf8 U_CFG_TEST_NET_STATUS_CELL U_CFG_TEST_NET_STATUS_SHORT_RANGE U_DEBUG_UTILS_DUMP_THREADS | diff --git a/port/platform/common/automation/scripts/u_select.py b/port/platform/common/automation/scripts/u_select.py index 33065594..ddade6ad 100644 --- a/port/platform/common/automation/scripts/u_select.py +++ b/port/platform/common/automation/scripts/u_select.py @@ -41,7 +41,7 @@ EXT_CODE = ["c", "cpp", "h", "hpp"] # The instances to always run: CodeChecker, Doxygen, AStyle, size, ubxlib.h and malloc checking -INSTANCES_ALWAYS = [[1], [2], [4], [5], [6,1], [6,2], [7], [8], [9]] +INSTANCES_ALWAYS = [[1], [2], [4,1], [4,2], [4,3], [4,4], [5], [6,1], [6,2], [7], [8], [9]] def instances_string(instances): '''Return a string of the form "1.2.3, 0.1"''' diff --git a/port/platform/static_size/Makefile b/port/platform/static_size/Makefile index 4a9abd8d..1c853506 100644 --- a/port/platform/static_size/Makefile +++ b/port/platform/static_size/Makefile @@ -47,8 +47,16 @@ LDFLAGS_NO_FLOAT += -Wl,-Map=$(OUTDIR_NO_FLOAT)/static_size_no_float.map CFLAGS_FLOAT += -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 LDFLAGS_FLOAT += -Wl,-Map=$(OUTDIR_FLOAT)/static_size.map -lm -# Include ubxlib src and inc +# Include ubxlib src and inc, allowing -DUBXLIB_FEATURES to specify a single one of +# cell, gnss or short_range as a -Dblah value in CFLAGS, e.g. +# CFLAGS= -DUBXLIB_FEATURES=cell -DU_CFG_TEST_CELL_MODULE_TYPE=U_CELL_MODULE_TYPE_SARA_R5 ... +DEF = $(filter -DUBXLIB_FEATURES=%,$(CFLAGS)) +ifneq "$(DEF)" "" +UBXLIB_FEATURES = $(subst -DUBXLIB_FEATURES=,,$(DEF)) +else UBXLIB_FEATURES = cell gnss short_range +endif +$(info UBXLIB_FEATURES is ${UBXLIB_FEATURES}) # ubxlib.mk will define UBXLIB_INC, UBXLIB_PRIVATE_INC and UBXLIB_SRC for us include $(UBXLIB_BASE)/port/ubxlib.mk diff --git a/port/platform/windows/mcu/win32/runner/CMakeLists.txt b/port/platform/windows/mcu/win32/runner/CMakeLists.txt index d22e09cf..a971b9bc 100644 --- a/port/platform/windows/mcu/win32/runner/CMakeLists.txt +++ b/port/platform/windows/mcu/win32/runner/CMakeLists.txt @@ -8,6 +8,8 @@ if (MSVC) set(CMAKE_CXX_STANDARD 20) # Warnings as errors and ignore a few warnings add_compile_options(/J /WX /wd4068 /wd4090 /wd4838 /wd4996 /wd4061 /wd4309 /wd5045) + # Switch off warning about duplicate functions since we use WEAK which MSVC doesn't _need_ but then complains about there being two objects... + set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4006" CACHE STRING "Linker flag" FORCE) else() # GCC-compatible options add_compile_options(-Wall -Wextra -Werror) diff --git a/port/ubxlib.cmake b/port/ubxlib.cmake index 96b968fb..de899ce9 100644 --- a/port/ubxlib.cmake +++ b/port/ubxlib.cmake @@ -55,6 +55,20 @@ function(u_add_module_dir feature module_dir) if (NOT EXISTS ${module_dir}) message(FATAL_ERROR "Directory does not exist: ${module_dir}") endif() + # Includes are always brought in: costs nothing + if(EXISTS ${module_dir}/api) + list(APPEND UBXLIB_INC ${module_dir}/api) + endif() + if(EXISTS ${module_dir}/src) + list(APPEND UBXLIB_PRIVATE_INC ${module_dir}/src) + endif() + if(EXISTS ${module_dir}/test) + list(APPEND UBXLIB_TEST_INC ${module_dir}/test) + endif() + set(UBXLIB_INC ${UBXLIB_INC} PARENT_SCOPE) + set(UBXLIB_PRIVATE_INC ${UBXLIB_PRIVATE_INC} PARENT_SCOPE) + set(UBXLIB_TEST_INC ${UBXLIB_TEST_INC} PARENT_SCOPE) + # Source files only brought in if the feature is present if (${feature} IN_LIST UBXLIB_FEATURES) if(EXISTS ${module_dir}/src) u_add_source_dir(${feature} ${module_dir}/src) @@ -62,20 +76,8 @@ function(u_add_module_dir feature module_dir) if(EXISTS ${module_dir}/test) u_add_test_source_dir(${feature} ${module_dir}/test) endif() - if(EXISTS ${module_dir}/api) - list(APPEND UBXLIB_INC ${module_dir}/api) - endif() - if(EXISTS ${module_dir}/src) - list(APPEND UBXLIB_PRIVATE_INC ${module_dir}/src) - endif() - if(EXISTS ${module_dir}/test) - list(APPEND UBXLIB_TEST_INC ${module_dir}/test) - endif() set(UBXLIB_SRC ${UBXLIB_SRC} PARENT_SCOPE) - set(UBXLIB_INC ${UBXLIB_INC} PARENT_SCOPE) - set(UBXLIB_PRIVATE_INC ${UBXLIB_PRIVATE_INC} PARENT_SCOPE) set(UBXLIB_TEST_SRC ${UBXLIB_TEST_SRC} PARENT_SCOPE) - set(UBXLIB_TEST_INC ${UBXLIB_TEST_INC} PARENT_SCOPE) endif() endfunction() @@ -118,12 +120,19 @@ list(APPEND UBXLIB_PRIVATE_INC # Device and network require special care since they contains stub & optional files list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/network/src/u_network.c) list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/network/src/u_network_shared.c) +list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/network/src/u_network_private_ble_extmod_stub.c) +list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/network/src/u_network_private_cell_stub.c) +list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/network/src/u_network_private_gnss_stub.c) +list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/network/src/u_network_private_wifi_stub.c) list(APPEND UBXLIB_INC ${UBXLIB_BASE}/common/network/api) list(APPEND UBXLIB_PRIVATE_INC ${UBXLIB_BASE}/common/network/src) list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device.c) list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device_serial.c) list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device_shared.c) list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device_private.c) +list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device_private_cell_stub.c) +list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device_private_gnss_stub.c) +list(APPEND UBXLIB_SRC ${UBXLIB_BASE}/common/device/src/u_device_private_short_range_stub.c) list(APPEND UBXLIB_INC ${UBXLIB_BASE}/common/device/api) list(APPEND UBXLIB_PRIVATE_INC ${UBXLIB_BASE}/common/device/src) diff --git a/port/ubxlib.mk b/port/ubxlib.mk index 65f9e557..60b2b22e 100644 --- a/port/ubxlib.mk +++ b/port/ubxlib.mk @@ -43,12 +43,19 @@ UBXLIB_PRIVATE_INC += \ # Device and network require special care since they contain stub & optional files UBXLIB_SRC += ${UBXLIB_BASE}/common/network/src/u_network.c UBXLIB_SRC += ${UBXLIB_BASE}/common/network/src/u_network_shared.c +UBXLIB_SRC += ${UBXLIB_BASE}/common/network/src/u_network_private_ble_extmod_stub.c +UBXLIB_SRC += ${UBXLIB_BASE}/common/network/src/u_network_private_cell_stub.c +UBXLIB_SRC += ${UBXLIB_BASE}/common/network/src/u_network_private_gnss_stub.c +UBXLIB_SRC += ${UBXLIB_BASE}/common/network/src/u_network_private_wifi_stub.c UBXLIB_INC += ${UBXLIB_BASE}/common/network/api UBXLIB_PRIVATE_INC += ${UBXLIB_BASE}/common/network/src UBXLIB_SRC += ${UBXLIB_BASE}/common/device/src/u_device.c UBXLIB_SRC += ${UBXLIB_BASE}/common/device/src/u_device_serial.c UBXLIB_SRC += ${UBXLIB_BASE}/common/device/src/u_device_shared.c UBXLIB_SRC += ${UBXLIB_BASE}/common/device/src/u_device_private.c +UBXLIB_SRC += ${UBXLIB_BASE}/common/device/src/u_device_private_cell_stub.c +UBXLIB_SRC += ${UBXLIB_BASE}/common/device/src/u_device_private_gnss_stub.c +UBXLIB_SRC += ${UBXLIB_BASE}/common/device/src/u_device_private_short_range_stub.c UBXLIB_INC += ${UBXLIB_BASE}/common/device/api UBXLIB_PRIVATE_INC += ${UBXLIB_BASE}/common/device/src @@ -67,6 +74,16 @@ UBXLIB_SRC += \ ${UBXLIB_BASE}/common/network/src/u_network_private_ble_intmod.c \ ${UBXLIB_BASE}/common/network/src/u_network_private_wifi.c \ ${UBXLIB_BASE}/common/device/src/u_device_private_short_range.c +else +# Always add all of the includes +UBXLIB_INC += \ + ${UBXLIB_BASE}/common/short_range/api \ + ${UBXLIB_BASE}/ble/api \ + ${UBXLIB_BASE}/wifi/api +UBXLIB_PRIVATE_INC += \ + ${UBXLIB_BASE}/common/short_range/src \ + ${UBXLIB_BASE}/ble/src \ + ${UBXLIB_BASE}/wifi/src endif # Optional cell related files and directories @@ -75,6 +92,12 @@ UBXLIB_MODULE_DIRS += ${UBXLIB_BASE}/cell UBXLIB_SRC += \ ${UBXLIB_BASE}/common/network/src/u_network_private_cell.c \ ${UBXLIB_BASE}/common/device/src/u_device_private_cell.c +else +# Always add all of the includes +UBXLIB_INC += \ + ${UBXLIB_BASE}/cell/api +UBXLIB_PRIVATE_INC += \ + ${UBXLIB_BASE}/cell/src endif # Optional GNSS related files and directories @@ -83,6 +106,12 @@ UBXLIB_MODULE_DIRS += ${UBXLIB_BASE}/gnss UBXLIB_SRC += \ ${UBXLIB_BASE}/common/network/src/u_network_private_gnss.c \ ${UBXLIB_BASE}/common/device/src/u_device_private_gnss.c +else +# Always add all of the includes +UBXLIB_INC += \ + ${UBXLIB_BASE}/gnss/api +UBXLIB_PRIVATE_INC += \ + ${UBXLIB_BASE}/gnss/src endif # lib_common diff --git a/wifi/api/u_wifi_mqtt.h b/wifi/api/u_wifi_mqtt.h index c789d8d3..82f6a0e7 100644 --- a/wifi/api/u_wifi_mqtt.h +++ b/wifi/api/u_wifi_mqtt.h @@ -56,6 +56,18 @@ typedef enum { U_WIFI_MQTT_QOS_MAX_NUM } uWifiMqttQos_t; +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uWifiMqttPrivateLink(void); + /* ---------------------------------------------------------------- * FUNCTIONS: * -------------------------------------------------------------- */ diff --git a/wifi/api/u_wifi_sock.h b/wifi/api/u_wifi_sock.h index da366b5f..baf58d34 100644 --- a/wifi/api/u_wifi_sock.h +++ b/wifi/api/u_wifi_sock.h @@ -99,6 +99,18 @@ extern "C" { typedef void (*uWifiSockCallback_t)(uDeviceHandle_t devHandle, int32_t sockHandle); +/* ---------------------------------------------------------------- + * FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +/** Workaround for Espressif linker missing out files that + * only contain functions which also have weak alternatives + * (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899). + * + * You can ignore this function. + */ +void uWifiSockPrivateLink(void); + /* ---------------------------------------------------------------- * FUNCTIONS: INIT/DEINIT * -------------------------------------------------------------- */ diff --git a/wifi/src/u_wifi.c b/wifi/src/u_wifi.c index 4c647c53..cfd99c42 100644 --- a/wifi/src/u_wifi.c +++ b/wifi/src/u_wifi.c @@ -51,6 +51,16 @@ #include "u_hex_bin_convert.h" +// THe headers below are necessary to work around an Espressif linker problem, see uWifiInit() +#include "u_network.h" +#include "u_network_config_wifi.h" +#include "u_network_private_wifi.h" +#include "u_sock.h" +#include "u_wifi_sock.h" // For uWifiSockPrivateLink() +#include "u_mqtt_common.h" +#include "u_mqtt_client.h" +#include "u_wifi_mqtt.h" // For uWifiMqttPrivateLink() + /* ---------------------------------------------------------------- * COMPILE-TIME MACROS * -------------------------------------------------------------- */ @@ -464,6 +474,18 @@ static void UUND_urc(uAtClientHandle_t atHandle, // Initialise the wifi driver. int32_t uWifiInit() { + // Workaround for Espressif linker missing out files that + // only contain functions which also have weak alternatives + // (see https://www.esp32.com/viewtopic.php?f=13&t=8418&p=35899) + // Basically any file that might end up containing only functions + // that also have WEAK linked counterparts will be lost, so we need + // to add a dummy function in those files and call it from somewhere + // that will always be present in the build, which for Wifi we + // choose to be here + uNetworkPrivateWifiLink(); + uWifiSockPrivateLink(); + uWifiMqttPrivateLink(); + return uShortRangeInit(); } diff --git a/wifi/src/u_wifi_mqtt.c b/wifi/src/u_wifi_mqtt.c index e352c857..6db7e269 100644 --- a/wifi/src/u_wifi_mqtt.c +++ b/wifi/src/u_wifi_mqtt.c @@ -827,6 +827,19 @@ static int32_t configureMqttSessionConnection(uWifiMqttSession_t *pMqttSession, return err; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uWifiMqttPrivateLink() +{ + //dummy +} + +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS + * -------------------------------------------------------------- */ + int32_t uWifiMqttInit(uDeviceHandle_t devHandle, void **ppMqttSession) { uShortRangePrivateInstance_t *pInstance; diff --git a/wifi/src/u_wifi_sock.c b/wifi/src/u_wifi_sock.c index 9a427bf0..e71ee321 100644 --- a/wifi/src/u_wifi_sock.c +++ b/wifi/src/u_wifi_sock.c @@ -695,6 +695,15 @@ int32_t deinitInstance(uDeviceHandle_t devHandle) return errnoLocal; } +/* ---------------------------------------------------------------- + * PUBLIC FUNCTIONS: WORKAROUND FOR LINKER ISSUE + * -------------------------------------------------------------- */ + +void uWifiSockPrivateLink() +{ + //dummy +} + /* ---------------------------------------------------------------- * PUBLIC FUNCTIONS * ------------------------------------------------------------- */