Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a src/platform/Darwin and get it to link with the iOS demo app #1497

Merged
merged 1 commit into from
Jul 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -996,11 +996,11 @@ AC_DEFINE_UNQUOTED([CONFIG_NETWORK_LAYER_INET],[${CONFIG_NETWORK_LAYER_INET}],[D
AC_MSG_CHECKING([device layer])
AC_ARG_WITH(device-layer,
[AS_HELP_STRING([--with-device-layer=LAYER],
[Specify the target environment for the CHIP Device Layer. Choose one of: efr32, esp32, nrf5, linux, or none @<:@default=none@:>@.])],
[Specify the target environment for the CHIP Device Layer. Choose one of: darwin, efr32, esp32, nrf5, linux, or none @<:@default=none@:>@.])],
[
case "${with_device_layer}" in

efr32|esp32|nrf5|linux|none)
darwin|efr32|esp32|nrf5|linux|none)
;;

*)
Expand All @@ -1013,16 +1013,24 @@ AC_ARG_WITH(device-layer,
AC_MSG_RESULT(${with_device_layer})

# Disable all device layer targets by default
CHIP_DEVICE_LAYER_TARGET_LINUX=0
CHIP_DEVICE_LAYER_TARGET_DARWIN=0
CHIP_DEVICE_LAYER_TARGET_EFR32=0
CHIP_DEVICE_LAYER_TARGET_ESP32=0
CHIP_DEVICE_LAYER_TARGET_NRF5=0
CHIP_DEVICE_LAYER_TARGET_EFR32=0
CHIP_DEVICE_LAYER_TARGET_LINUX=0

case "${with_device_layer}" in
linux)

darwin)
CONFIG_DEVICE_LAYER=1
CHIP_DEVICE_LAYER_TARGET=Linux
CHIP_DEVICE_LAYER_TARGET_LINUX=1
CHIP_DEVICE_LAYER_TARGET=Darwin
CHIP_DEVICE_LAYER_TARGET_DARWIN=1
;;

efr32)
CONFIG_DEVICE_LAYER=1
CHIP_DEVICE_LAYER_TARGET=EFR32
CHIP_DEVICE_LAYER_TARGET_EFR32=1
;;

esp32)
Expand All @@ -1037,10 +1045,10 @@ nrf5)
CHIP_DEVICE_LAYER_TARGET_NRF5=1
;;

efr32)
linux)
CONFIG_DEVICE_LAYER=1
CHIP_DEVICE_LAYER_TARGET=EFR32
CHIP_DEVICE_LAYER_TARGET_EFR32=1
CHIP_DEVICE_LAYER_TARGET=Linux
CHIP_DEVICE_LAYER_TARGET_LINUX=1
;;

none)
Expand All @@ -1056,6 +1064,10 @@ AC_DEFINE_UNQUOTED([CONFIG_DEVICE_LAYER],[${CONFIG_DEVICE_LAYER}],[Define to 1 i
AC_SUBST(CHIP_DEVICE_LAYER_TARGET)
AC_DEFINE_UNQUOTED([CHIP_DEVICE_LAYER_TARGET],[${CHIP_DEVICE_LAYER_TARGET}],[Target platform name for CHIP Device Layer.])

AC_SUBST(CHIP_DEVICE_LAYER_TARGET_DARWIN)
AM_CONDITIONAL([CHIP_DEVICE_LAYER_TARGET_DARWIN], [test "${CHIP_DEVICE_LAYER_TARGET_DARWIN}" = 1])
AC_DEFINE_UNQUOTED([CHIP_DEVICE_LAYER_TARGET_DARWIN],[${CHIP_DEVICE_LAYER_TARGET_DARWIN}],[Define to 1 if you want to build the CHIP Device Layer for Darwin platforms.])

AC_SUBST(CHIP_DEVICE_LAYER_TARGET_EFR32)
AM_CONDITIONAL([CHIP_DEVICE_LAYER_TARGET_EFR32], [test "${CHIP_DEVICE_LAYER_TARGET_EFR32}" = 1])
AC_DEFINE_UNQUOTED([CHIP_DEVICE_LAYER_TARGET_EFR32],[${CHIP_DEVICE_LAYER_TARGET_EFR32}],[Define to 1 if you want to build the CHIP Device Layer for Silicon Labs EFR32 platforms.])
Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
1E3DE6E124AF86F50028DC40 /* libDeviceLayer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E3DE6E024AF86F50028DC40 /* libDeviceLayer.a */; };
2C4DF09E248B2C60009307CB /* libmbedtls.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2C4DF09D248B2C60009307CB /* libmbedtls.a */; };
515C401C2486BF43004C4DB3 /* CHIPOnOff.mm in Sources */ = {isa = PBXBuildFile; fileRef = 515C401A2486BF43004C4DB3 /* CHIPOnOff.mm */; };
515C401D2486BF43004C4DB3 /* CHIPOnOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 515C401B2486BF43004C4DB3 /* CHIPOnOff.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -41,6 +42,7 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
1E3DE6E024AF86F50028DC40 /* libDeviceLayer.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libDeviceLayer.a; path = "lib/libDeviceLayer.a"; sourceTree = BUILD_PRODUCT_DIR; };
2C4DF09D248B2C60009307CB /* libmbedtls.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libmbedtls.a; path = lib/libmbedtls.a; sourceTree = BUILT_PRODUCTS_DIR; };
515C401A2486BF43004C4DB3 /* CHIPOnOff.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPOnOff.mm; sourceTree = "<group>"; };
515C401B2486BF43004C4DB3 /* CHIPOnOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPOnOff.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -72,6 +74,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
1E3DE6E124AF86F50028DC40 /* libDeviceLayer.a in Frameworks */,
BA09EB43247477BA00605257 /* libCHIP.a in Frameworks */,
2C4DF09E248B2C60009307CB /* libmbedtls.a in Frameworks */,
BA09EB44247477BC00605257 /* libSetupPayload.a in Frameworks */,
Expand Down Expand Up @@ -147,6 +150,7 @@
2C4DF09D248B2C60009307CB /* libmbedtls.a */,
BA09EB3F2474762900605257 /* libCHIP.a */,
BA09EB402474762900605257 /* libSetupPayload.a */,
1E3DE6E024AF86F50028DC40 /* libDeviceLayer.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down
2 changes: 2 additions & 0 deletions src/darwin/Framework/chip_xcode_build_connector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ configure_OPTIONS+=(
--disable-shared
--disable-tests
--disable-tools
--with-device-layer=darwin
--with-logging-style=external
--with-chip-system-project-includes=no
--with-chip-inet-project-includes=no
Expand All @@ -114,6 +115,7 @@ configure_OPTIONS+=(

make V=1 install-data # all the headers
make V=1 -C src/lib install # libCHIP.a
make V=1 -C src/platform install # libDeviceLayer.a
make V=1 -C src/setup_payload install # libSetupPayload.a
make V=1 -C third_party/mbedtls install # libmbedtls.a
)
38 changes: 38 additions & 0 deletions src/platform/Darwin/BlePlatformConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
*
* 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
* Platform-specific configuration overrides for the CHIP BLE
* Layer on Darwin platforms.
*
*/

#ifndef BLE_PLATFORM_CONFIG_H
#define BLE_PLATFORM_CONFIG_H

// ==================== Platform Adaptations ====================

#define BLE_CONNECTION_OBJECT uint16_t
#define BLE_CONNECTION_UNINITIALIZED ((uint16_t) -1)
#define BLE_MAX_RECEIVE_WINDOW_SIZE 5

// ========== Platform-specific Configuration Overrides =========

/* none so far */

#endif // BLE_PLATFORM_CONFIG_H
87 changes: 87 additions & 0 deletions src/platform/Darwin/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
*
* 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
* Platform-specific configuration overrides for the chip Device Layer
* on Darwin platforms.
*/

#ifndef CHIP_DEVICE_PLATFORM_CONFIG_H
#define CHIP_DEVICE_PLATFORM_CONFIG_H

// ==================== Platform Adaptations ====================

#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0

#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 0

#define CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE 0

#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0
#define CHIP_DEVICE_CONFIG_ENABLE_SERVICE_DIRECTORY_TIME_SYNC 0

#define CHIP_DEVICE_CONFIG_PERSISTED_STORAGE_CRIT_EIDC_KEY 2
#define CHIP_DEVICE_CONFIG_PERSISTED_STORAGE_PROD_EIDC_KEY 3
#define CHIP_DEVICE_CONFIG_PERSISTED_STORAGE_INFO_EIDC_KEY 4
#define CHIP_DEVICE_CONFIG_PERSISTED_STORAGE_DEBUG_EIDC_KEY 5

// ========== Platform-specific Configuration =========

// These are configuration options that are unique to Darwin platforms.
// These can be overridden by the application as needed.

/**
* @def CHIP_DEVICE_LAYER_BLE_OBSERVER_PRIORITY
*
* The priority of the SoftDevice observer event handler registered by the
* CHIP BleLayer.
*/
#ifndef CHIP_DEVICE_LAYER_BLE_OBSERVER_PRIORITY
#define CHIP_DEVICE_LAYER_BLE_OBSERVER_PRIORITY 3
#endif // CHIP_DEVICE_LAYER_BLE_OBSERVER_PRIORITY

/**
* @def CHIP_DEVICE_LAYER_BLE_CONN_CFG_TAG
*
* The SoftDevice BLE connection configuration tag used by the CHIP
* BleLayer.
*/
#ifndef CHIP_DEVICE_LAYER_BLE_CONN_CFG_TAG
#define CHIP_DEVICE_LAYER_BLE_CONN_CFG_TAG 1
#endif // CHIP_DEVICE_LAYER_BLE_CONN_CFG_TAG

// ========== Platform-specific Configuration Overrides =========

#ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE
#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE 8192
#endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE

#ifndef CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE
#define CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE 8192
#endif // CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE

#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0
#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY 0

// TODO: CHIP has redesigned the crypto interface, pending on the final version of CHIP HASH APIs
#define CHIP_DEVICE_CONFIG_LOG_PROVISIONING_HASH 0

#endif // CHIP_DEVICE_PLATFORM_CONFIG_H
78 changes: 78 additions & 0 deletions src/platform/Darwin/CHIPDevicePlatformEvent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
*
* 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
* Defines platform-specific event types and data for the chip
* Device Layer on Darwin platforms.
*/

#ifndef CHIP_DEVICE_PLATFORM_EVENT_H
#define CHIP_DEVICE_PLATFORM_EVENT_H

#include <platform/CHIPDeviceEvent.h>

namespace chip {
namespace System {
class PacketBuffer;
}
} // namespace chip

namespace chip {
namespace DeviceLayer {

namespace DeviceEventType {

/**
* Enumerates platform-specific event types that are visible to the application.
*/
enum PublicPlatformSpecificEventTypes
{
/* None currently defined */
};

/**
* Enumerates platform-specific event types that are internal to the chip Device Layer.
*/
enum InternalPlatformSpecificEventTypes
{
kPlatformDarwinEvent = kRange_InternalPlatformSpecific,
kPlatformDarwinBleC1WriteEvent,
kPlatformDarwinBleOutOfBuffersEvent,
};

} // namespace DeviceEventType

/**
* Represents platform-specific event information for Linux platforms.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darwin * platforms

*/
struct ChipDevicePlatformEvent final
{
union
{
struct
{
uint16_t ConnId;
::chip::System::PacketBuffer * Data;
} BleC1WriteEvent;
};
};

} // namespace DeviceLayer
} // namespace chip

#endif // CHIP_DEVICE_PLATFORM_EVENT_H
Loading