From 804eb542df58faa0901c2bdfac18117556e6ac72 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 23 Oct 2020 16:38:48 -0400 Subject: [PATCH] Convert various app/util files to C++ --- examples/lighting-app/efr32/BUILD.gn | 8 ++++---- examples/lighting-app/lighting-common/BUILD.gn | 8 ++++---- examples/lighting-app/nrfconnect/CMakeLists.txt | 8 ++++---- examples/lock-app/efr32/BUILD.gn | 8 ++++---- examples/lock-app/lock-common/BUILD.gn | 8 ++++---- examples/lock-app/nrfconnect/CMakeLists.txt | 8 ++++---- src/app/clusters/ias-zone-client/ias-zone-client.h | 8 ++++++++ src/app/util/{af-main-common.c => af-main-common.cpp} | 0 src/app/util/af-types.h | 2 +- src/app/util/attribute-table.h | 8 ++++++++ src/app/util/{message.c => message.cpp} | 0 ...rocess-global-message.c => process-global-message.cpp} | 0 src/app/util/types_stub.h | 8 ++++---- src/app/util/{util.c => util.cpp} | 4 +++- 14 files changed, 48 insertions(+), 30 deletions(-) rename src/app/util/{af-main-common.c => af-main-common.cpp} (100%) rename src/app/util/{message.c => message.cpp} (100%) rename src/app/util/{process-global-message.c => process-global-message.cpp} (100%) rename src/app/util/{util.c => util.cpp} (99%) diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index d27c797b4c6b89..eef9b428e44088 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -88,7 +88,7 @@ efr32_executable("lighting_app") { "${chip_root}/examples/common/chip-app-server/DataModelHandler.cpp", "${chip_root}/src/app/clusters/on-off-server/on-off.c", "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.c", + "${chip_root}/src/app/util/af-main-common.cpp", "${chip_root}/src/app/util/attribute-size.c", "${chip_root}/src/app/util/attribute-storage.c", "${chip_root}/src/app/util/attribute-table.c", @@ -96,10 +96,10 @@ efr32_executable("lighting_app") { "${chip_root}/src/app/util/chip-message-send.cpp", "${chip_root}/src/app/util/client-api.c", "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.c", + "${chip_root}/src/app/util/message.cpp", "${chip_root}/src/app/util/process-cluster-message.c", - "${chip_root}/src/app/util/process-global-message.c", - "${chip_root}/src/app/util/util.c", + "${chip_root}/src/app/util/process-global-message.cpp", + "${chip_root}/src/app/util/util.cpp", "${examples_plat_dir}/${efr32_family}/${efr32_board}/hal-config.h", "${examples_plat_dir}/${efr32_family}/${efr32_board}/init_board.c", "${examples_plat_dir}/${efr32_family}/${efr32_board}/init_mcu.c", diff --git a/examples/lighting-app/lighting-common/BUILD.gn b/examples/lighting-app/lighting-common/BUILD.gn index 65bc604f0522b6..5a6dc7a40859a7 100644 --- a/examples/lighting-app/lighting-common/BUILD.gn +++ b/examples/lighting-app/lighting-common/BUILD.gn @@ -26,7 +26,7 @@ source_set("lighting-common") { "${chip_root}/examples/common/chip-app-server/DataModelHandler.cpp", "${chip_root}/src/app/clusters/on-off-server/on-off.c", "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.c", + "${chip_root}/src/app/util/af-main-common.cpp", "${chip_root}/src/app/util/attribute-size.c", "${chip_root}/src/app/util/attribute-storage.c", "${chip_root}/src/app/util/attribute-table.c", @@ -34,10 +34,10 @@ source_set("lighting-common") { "${chip_root}/src/app/util/chip-message-send.cpp", "${chip_root}/src/app/util/client-api.c", "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.c", + "${chip_root}/src/app/util/message.cpp", "${chip_root}/src/app/util/process-cluster-message.c", - "${chip_root}/src/app/util/process-global-message.c", - "${chip_root}/src/app/util/util.c", + "${chip_root}/src/app/util/process-global-message.cpp", + "${chip_root}/src/app/util/util.cpp", "gen/call-command-handler.c", "gen/callback-stub.c", "gen/znet-bookkeeping.c", diff --git a/examples/lighting-app/nrfconnect/CMakeLists.txt b/examples/lighting-app/nrfconnect/CMakeLists.txt index 8319e0fcc9b356..b20fc35b2ae5fc 100644 --- a/examples/lighting-app/nrfconnect/CMakeLists.txt +++ b/examples/lighting-app/nrfconnect/CMakeLists.txt @@ -43,7 +43,7 @@ target_sources(app PRIVATE ${CHIP_APP_SERVER}/QRCodeUtil.cpp ${CHIP_APP_SERVER}/RendezvousServer.cpp ${CHIP_ROOT}/src/app/util/af-event.cpp - ${CHIP_ROOT}/src/app/util/af-main-common.c + ${CHIP_ROOT}/src/app/util/af-main-common.cpp ${CHIP_ROOT}/src/app/util/attribute-size.c ${CHIP_ROOT}/src/app/util/attribute-storage.c ${CHIP_ROOT}/src/app/util/attribute-table.c @@ -51,8 +51,8 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/util/chip-message-send.cpp ${CHIP_ROOT}/src/app/util/client-api.c ${CHIP_ROOT}/src/app/util/ember-print.cpp - ${CHIP_ROOT}/src/app/util/message.c + ${CHIP_ROOT}/src/app/util/message.cpp ${CHIP_ROOT}/src/app/util/process-cluster-message.c - ${CHIP_ROOT}/src/app/util/process-global-message.c - ${CHIP_ROOT}/src/app/util/util.c + ${CHIP_ROOT}/src/app/util/process-global-message.cpp + ${CHIP_ROOT}/src/app/util/util.cpp ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off.c) diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index 57f62884e0c32e..fa681ff520d236 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -88,7 +88,7 @@ efr32_executable("lock_app") { "${chip_root}/examples/common/chip-app-server/DataModelHandler.cpp", "${chip_root}/src/app/clusters/on-off-server/on-off.c", "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.c", + "${chip_root}/src/app/util/af-main-common.cpp", "${chip_root}/src/app/util/attribute-size.c", "${chip_root}/src/app/util/attribute-storage.c", "${chip_root}/src/app/util/attribute-table.c", @@ -96,10 +96,10 @@ efr32_executable("lock_app") { "${chip_root}/src/app/util/chip-message-send.cpp", "${chip_root}/src/app/util/client-api.c", "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.c", + "${chip_root}/src/app/util/message.cpp", "${chip_root}/src/app/util/process-cluster-message.c", - "${chip_root}/src/app/util/process-global-message.c", - "${chip_root}/src/app/util/util.c", + "${chip_root}/src/app/util/process-global-message.cpp", + "${chip_root}/src/app/util/util.cpp", "${examples_plat_dir}/${efr32_family}/${efr32_board}/hal-config.h", "${examples_plat_dir}/${efr32_family}/${efr32_board}/init_board.c", "${examples_plat_dir}/${efr32_family}/${efr32_board}/init_mcu.c", diff --git a/examples/lock-app/lock-common/BUILD.gn b/examples/lock-app/lock-common/BUILD.gn index 80f2286b477dd0..db58829f96e8a9 100644 --- a/examples/lock-app/lock-common/BUILD.gn +++ b/examples/lock-app/lock-common/BUILD.gn @@ -27,7 +27,7 @@ source_set("lock-common") { "${chip_root}/examples/common/chip-app-server/DataModelHandler.cpp", "${chip_root}/src/app/clusters/on-off-server/on-off.c", "${chip_root}/src/app/util/af-event.cpp", - "${chip_root}/src/app/util/af-main-common.c", + "${chip_root}/src/app/util/af-main-common.cpp", "${chip_root}/src/app/util/attribute-size.c", "${chip_root}/src/app/util/attribute-storage.c", "${chip_root}/src/app/util/attribute-table.c", @@ -35,10 +35,10 @@ source_set("lock-common") { "${chip_root}/src/app/util/chip-message-send.cpp", "${chip_root}/src/app/util/client-api.c", "${chip_root}/src/app/util/ember-print.cpp", - "${chip_root}/src/app/util/message.c", + "${chip_root}/src/app/util/message.cpp", "${chip_root}/src/app/util/process-cluster-message.c", - "${chip_root}/src/app/util/process-global-message.c", - "${chip_root}/src/app/util/util.c", + "${chip_root}/src/app/util/process-global-message.cpp", + "${chip_root}/src/app/util/util.cpp", "gen/call-command-handler.c", "gen/callback-stub.c", "gen/znet-bookkeeping.c", diff --git a/examples/lock-app/nrfconnect/CMakeLists.txt b/examples/lock-app/nrfconnect/CMakeLists.txt index 1156bcb89dc71c..f4f656d297047b 100644 --- a/examples/lock-app/nrfconnect/CMakeLists.txt +++ b/examples/lock-app/nrfconnect/CMakeLists.txt @@ -43,7 +43,7 @@ target_sources(app PRIVATE ${CHIP_APP_SERVER}/QRCodeUtil.cpp ${CHIP_APP_SERVER}/RendezvousServer.cpp ${CHIP_ROOT}/src/app/util/af-event.cpp - ${CHIP_ROOT}/src/app/util/af-main-common.c + ${CHIP_ROOT}/src/app/util/af-main-common.cpp ${CHIP_ROOT}/src/app/util/attribute-size.c ${CHIP_ROOT}/src/app/util/attribute-storage.c ${CHIP_ROOT}/src/app/util/attribute-table.c @@ -51,8 +51,8 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/util/chip-message-send.cpp ${CHIP_ROOT}/src/app/util/client-api.c ${CHIP_ROOT}/src/app/util/ember-print.cpp - ${CHIP_ROOT}/src/app/util/message.c + ${CHIP_ROOT}/src/app/util/message.cpp ${CHIP_ROOT}/src/app/util/process-cluster-message.c - ${CHIP_ROOT}/src/app/util/process-global-message.c - ${CHIP_ROOT}/src/app/util/util.c + ${CHIP_ROOT}/src/app/util/process-global-message.cpp + ${CHIP_ROOT}/src/app/util/util.cpp ${CHIP_ROOT}/src/app/clusters/on-off-server/on-off.c) diff --git a/src/app/clusters/ias-zone-client/ias-zone-client.h b/src/app/clusters/ias-zone-client/ias-zone-client.h index 7a14dc5e789433..bec1a5f977d5a1 100644 --- a/src/app/clusters/ias-zone-client/ias-zone-client.h +++ b/src/app/clusters/ias-zone-client/ias-zone-client.h @@ -56,6 +56,10 @@ extern IasZoneDevice emberAfIasZoneClientKnownServers[]; #define UNKNOWN_ZONE_ID 0xFF +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + void emAfClearServers(void); void emberAfPluginIasZoneClientZdoCallback(EmberNodeId emberNodeId, EmberApsFrame * apsFrame, uint8_t * message, uint16_t length); @@ -63,3 +67,7 @@ void emberAfPluginIasZoneClientZdoCallback(EmberNodeId emberNodeId, EmberApsFram void emberAfPluginIasZoneClientWriteAttributesResponseCallback(EmberAfClusterId clusterId, uint8_t * buffer, uint16_t bufLen); void emberAfPluginIasZoneClientReadAttributesResponseCallback(EmberAfClusterId clusterId, uint8_t * buffer, uint16_t bufLen); + +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus diff --git a/src/app/util/af-main-common.c b/src/app/util/af-main-common.cpp similarity index 100% rename from src/app/util/af-main-common.c rename to src/app/util/af-main-common.cpp diff --git a/src/app/util/af-types.h b/src/app/util/af-types.h index ee005ff535fb14..0d0c23a0633671 100644 --- a/src/app/util/af-types.h +++ b/src/app/util/af-types.h @@ -1500,7 +1500,7 @@ typedef struct EmberAfMessageSentFunction callback; EmberApsFrame * apsFrame; uint8_t * message; - uint16_t indexOrDestination; + uint64_t indexOrDestination; uint16_t messageLength; EmberOutgoingMessageType type; bool broadcast; diff --git a/src/app/util/attribute-table.h b/src/app/util/attribute-table.h index 0b6927cf50f302..c5eeec9aa2281a 100644 --- a/src/app/util/attribute-table.h +++ b/src/app/util/attribute-table.h @@ -46,6 +46,10 @@ #define ZCL_NULL_ATTRIBUTE_TABLE_INDEX 0xFFFF +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + // Remote devices writing attributes of local device EmberAfStatus emberAfWriteAttributeExternal(uint8_t endpoint, EmberAfClusterId cluster, EmberAfAttributeId attributeID, uint8_t mask, uint16_t manufacturerCode, uint8_t * dataPtr, @@ -68,4 +72,8 @@ EmberAfStatus emAfWriteAttribute(uint8_t endpoint, EmberAfClusterId cluster, Emb EmberAfStatus emAfReadAttribute(uint8_t endpoint, EmberAfClusterId cluster, EmberAfAttributeId attributeID, uint8_t mask, uint16_t manufacturerCode, uint8_t * dataPtr, uint16_t readLength, EmberAfAttributeType * dataType); +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + #endif // ZCL_UTIL_ATTRIBUTE_TABLE_H diff --git a/src/app/util/message.c b/src/app/util/message.cpp similarity index 100% rename from src/app/util/message.c rename to src/app/util/message.cpp diff --git a/src/app/util/process-global-message.c b/src/app/util/process-global-message.cpp similarity index 100% rename from src/app/util/process-global-message.c rename to src/app/util/process-global-message.cpp diff --git a/src/app/util/types_stub.h b/src/app/util/types_stub.h index 98916787499666..b216daca94efb6 100644 --- a/src/app/util/types_stub.h +++ b/src/app/util/types_stub.h @@ -1963,10 +1963,6 @@ typedef struct #define emberAfPluginColorControlServerComputePwmFromHsvCallback(endpoint) (void) 0 #define emberAfPluginColorControlServerComputePwmFromTempCallback(endpoint) (void) 0 -#ifdef __cplusplus -} // extern "C" -#endif // __cplusplus - /** * @brief Macro that copies the token value from non-volatile storage into a RAM * location. This macro can only be used with tokens that are defined using @@ -2002,4 +1998,8 @@ typedef struct uint32_t halCommonGetInt32uMillisecondTick(void); +#ifdef __cplusplus +} // extern "C" +#endif // __cplusplus + #endif // TYPES_STUB_H diff --git a/src/app/util/util.c b/src/app/util/util.cpp similarity index 99% rename from src/app/util/util.c rename to src/app/util/util.cpp index 14dc1a63caaf1d..a1af838675b1f6 100644 --- a/src/app/util/util.c +++ b/src/app/util/util.cpp @@ -69,7 +69,7 @@ const EmberAfClusterName zclClusterNames[] = { { ZCL_NULL_CLUSTER_ID, EMBER_AF_NULL_MANUFACTURER_CODE, NULL }, // terminator }; -static const EmberAfClusterCommand staticCmd; +static const EmberAfClusterCommand staticCmd = {}; EmberAfClusterCommand curCmd; // A pointer to the current command being processed // This struct is allocated on the stack inside @@ -112,12 +112,14 @@ uint8_t emAfExtendedPanId[EXTENDED_PAN_ID_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, }; +extern "C" { #ifdef EMBER_AF_GENERATED_PLUGIN_INIT_FUNCTION_DECLARATIONS EMBER_AF_GENERATED_PLUGIN_INIT_FUNCTION_DECLARATIONS #endif #ifdef EMBER_AF_GENERATED_PLUGIN_TICK_FUNCTION_DECLARATIONS EMBER_AF_GENERATED_PLUGIN_TICK_FUNCTION_DECLARATIONS #endif +} // extern "C" //------------------------------------------------------------------------------