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

Pull/k32w adaptation 15.4 #1420

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[K32W] Change namespace to Project CHIP
Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>
  • Loading branch information
doru91 committed Jul 2, 2020
commit 0e81c3f1a9962d19abffed78c6591d4e0e99be66
17 changes: 7 additions & 10 deletions src/platform/K32W/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020 Nest Labs, Inc.
* All rights reserved.
*
Expand All @@ -22,19 +23,16 @@
* for the K32W platforms.
*/

#include <Weave/DeviceLayer/internal/WeaveDeviceLayerInternal.h>
#include <Weave/DeviceLayer/internal/BLEManager.h>
#include <BleLayer/WeaveBleServiceData.h>
#include <new>
/* this file behaves like a config.h, comes first */
#include <platform/internal/CHIPDeviceLayerInternal.h>

#if WEAVE_DEVICE_CONFIG_ENABLE_WOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE


using namespace ::nl;
using namespace ::nl::Ble;

namespace nl {
namespace Weave {
namespace chip {
namespace DeviceLayer {
namespace Internal {

Expand All @@ -45,6 +43,5 @@ namespace {
}
} // namespace Internal
} // namespace DeviceLayer
} // namespace Weave
} // namespace nl
#endif // WEAVE_DEVICE_CONFIG_ENABLE_WOBLE
} // namespace chip
#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
74 changes: 40 additions & 34 deletions src/platform/K32W/BLEManagerImpl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020 Nest Labs, Inc.
* All rights reserved.
*
Expand All @@ -25,13 +26,14 @@
#ifndef BLE_MANAGER_IMPL_H
#define BLE_MANAGER_IMPL_H

#if WEAVE_DEVICE_CONFIG_ENABLE_WOBLE
#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

namespace nl {
namespace Weave {
namespace chip {
namespace DeviceLayer {
namespace Internal {

using namespace chip::Ble;

/**
* Concrete implementation of the NetworkProvisioningServer singleton object for the K32W platforms.
*/
Expand All @@ -56,34 +58,39 @@ class BLEManagerImpl final

// ===== Members that implement the BLEManager internal interface.

WEAVE_ERROR _Init(void);
WoBLEServiceMode _GetWoBLEServiceMode(void);
WEAVE_ERROR _SetWoBLEServiceMode(WoBLEServiceMode val);
CHIP_ERROR _Init(void);
CHIPoBLEServiceMode _GetCHIPoBLEServiceMode(void);
CHIP_ERROR _SetCHIPoBLEServiceMode(CHIPoBLEServiceMode val);
bool _IsAdvertisingEnabled(void);
WEAVE_ERROR _SetAdvertisingEnabled(bool val);
CHIP_ERROR _SetAdvertisingEnabled(bool val);
bool _IsFastAdvertisingEnabled(void);
WEAVE_ERROR _SetFastAdvertisingEnabled(bool val);
CHIP_ERROR _SetFastAdvertisingEnabled(bool val);
bool _IsAdvertising(void);
WEAVE_ERROR _GetDeviceName(char * buf, size_t bufSize);
WEAVE_ERROR _SetDeviceName(const char * deviceName);
CHIP_ERROR _GetDeviceName(char * buf, size_t bufSize);
CHIP_ERROR _SetDeviceName(const char * deviceName);
uint16_t _NumConnections(void);
void _OnPlatformEvent(const WeaveDeviceEvent * event);
::nl::Ble::BleLayer * _GetBleLayer(void) const;
void _OnPlatformEvent(const ChipDeviceEvent * event);
BleLayer * _GetBleLayer(void) const;

// ===== Members that implement virtual methods on BlePlatformDelegate.

bool SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const WeaveBleUUID * svcId, const WeaveBleUUID * charId) override;
bool UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const WeaveBleUUID * svcId, const WeaveBleUUID * charId) override;
bool SubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) override;
bool UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId) override;
bool CloseConnection(BLE_CONNECTION_OBJECT conId) override;
uint16_t GetMTU(BLE_CONNECTION_OBJECT conId) const override;
bool SendIndication(BLE_CONNECTION_OBJECT conId, const WeaveBleUUID * svcId, const WeaveBleUUID * charId, PacketBuffer * pBuf) override;
bool SendWriteRequest(BLE_CONNECTION_OBJECT conId, const WeaveBleUUID * svcId, const WeaveBleUUID * charId, PacketBuffer * pBuf) override;
bool SendReadRequest(BLE_CONNECTION_OBJECT conId, const WeaveBleUUID * svcId, const WeaveBleUUID * charId, PacketBuffer * pBuf) override;
bool SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQUEST_CONTEXT requestContext, const WeaveBleUUID * svcId, const WeaveBleUUID * charId) override;
bool SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId,
PacketBuffer * pBuf) override;
bool SendWriteRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId,
PacketBuffer * pBuf) override;
bool SendReadRequest(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId,
PacketBuffer * pBuf) override;
bool SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQUEST_CONTEXT requestContext, const ChipBleUUID * svcId,
const ChipBleUUID * charId) override;


// ===== Members that implement virtual methods on BleApplicationDelegate.

void NotifyWeaveConnectionClosed(BLE_CONNECTION_OBJECT conId) override;
void NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) override;

// ===== Members for internal use by the following friends.

Expand Down Expand Up @@ -117,17 +124,17 @@ class BLEManagerImpl final
uint8_t mAdvHandle;

void DriveBLEState(void);
WEAVE_ERROR ConfigureAdvertising(void);
//WEAVE_ERROR EncodeAdvertisingData(ble_gap_adv_data_t & gapAdvData);
WEAVE_ERROR StartAdvertising(void);
WEAVE_ERROR StopAdvertising(void);
void HandleSoftDeviceBLEEvent(const WeaveDeviceEvent * event);
WEAVE_ERROR HandleGAPConnect(const WeaveDeviceEvent * event);
WEAVE_ERROR HandleGAPDisconnect(const WeaveDeviceEvent * event);
WEAVE_ERROR HandleRXCharWrite(const WeaveDeviceEvent * event);
WEAVE_ERROR HandleTXCharCCCDWrite(const WeaveDeviceEvent * event);
WEAVE_ERROR HandleTXComplete(const WeaveDeviceEvent * event);
WEAVE_ERROR SetSubscribed(uint16_t conId);
CHIP_ERROR ConfigureAdvertising(void);
CHIP_ERROR EncodeAdvertisingData(ble_gap_adv_data_t & gapAdvData);
CHIP_ERROR StartAdvertising(void);
CHIP_ERROR StopAdvertising(void);
void HandleSoftDeviceBLEEvent(const ChipDeviceEvent * event);
CHIP_ERROR HandleGAPConnect(const ChipDeviceEvent * event);
CHIP_ERROR HandleGAPDisconnect(const ChipDeviceEvent * event);
CHIP_ERROR HandleRXCharWrite(const ChipDeviceEvent * event);
CHIP_ERROR HandleTXCharCCCDWrite(const ChipDeviceEvent * event);
CHIP_ERROR HandleTXComplete(const ChipDeviceEvent * event);
CHIP_ERROR SetSubscribed(uint16_t conId);
bool UnsetSubscribed(uint16_t conId);
bool IsSubscribed(uint16_t conId);

Expand Down Expand Up @@ -162,7 +169,7 @@ inline ::nl::Ble::BleLayer * BLEManagerImpl::_GetBleLayer() const
return (BleLayer *)(this);
}

inline BLEManager::WoBLEServiceMode BLEManagerImpl::_GetWoBLEServiceMode(void)
inline BLEManager::CHIPoBLEServiceMode BLEManagerImpl::_GetCHIPoBLEServiceMode(void)
{
return mServiceMode;
}
Expand All @@ -179,9 +186,8 @@ inline bool BLEManagerImpl::_IsFastAdvertisingEnabled(void)

} // namespace Internal
} // namespace DeviceLayer
} // namespace Weave
} // namespace nl
} // namespace chip

#endif // WEAVE_DEVICE_CONFIG_ENABLE_WOBLE
#endif // CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE

#endif // BLE_MANAGER_IMPL_H
5 changes: 3 additions & 2 deletions src/platform/K32W/BlePlatformConfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020 Google LLC.
* All rights reserved.
*
Expand All @@ -18,8 +19,8 @@

/**
* @file
* Platform-specific configuration overrides for the OpenWeave BLE
* Layer on nRF52 platforms using the Nordic nRF5 SDK.
* Platform-specific configuration overrides for the CHIP BLE
* Layer on K32W platforms using the NXP SDK.
*
*/

Expand Down
92 changes: 92 additions & 0 deletions src/platform/K32W/CHIPDevicePlatformConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020 Google LLC.
* All rights reserved.
*
* 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 K32W platforms using the NXP SDK.
*/


#ifndef CHIP_DEVICE_PLATFORM_CONFIG_H
#define CHIP_DEVICE_PLATFORM_CONFIG_H

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

#define K32W_NO_ERRORS 0
#define K32W_ENTRY_NOT_FOUND 1

#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION 0
#define CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP 0

#define CHIP_DEVICE_CONFIG_ENABLE_THREAD 1

#ifndef CHIP_DEVICE_CONFIG_ENABLE_WOBLE
#define CHIP_DEVICE_CONFIG_ENABLE_WOBLE 1
#endif

#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
#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 the K32W platform.
// 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 1
#define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0
#define CHIP_DEVICE_CONFIG_ENABLE_TUNNEL_TELEMETRY 0

#endif // CHIP_DEVICE_PLATFORM_CONFIG_H
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020 Nest Labs, Inc.
* All rights reserved.
*
Expand All @@ -18,25 +19,22 @@

/**
* @file
* Defines platform-specific event types and data for the Weave
* Defines platform-specific event types and data for the chip
* Device Layer on K32W061 platforms using the NXP SDK.
*/

#ifndef WEAVE_DEVICE_PLATFORM_EVENT_H
#define WEAVE_DEVICE_PLATFORM_EVENT_H
#ifndef CHIP_DEVICE_PLATFORM_EVENT_H
#define CHIP_DEVICE_PLATFORM_EVENT_H

#include <Weave/DeviceLayer/WeaveDeviceEvent.h>
#include <platform/CHIPDeviceEvent.h>

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

namespace nl {
namespace Weave {
namespace chip {
namespace DeviceLayer {

namespace DeviceEventType {
Expand All @@ -50,7 +48,7 @@ enum PublicPlatformSpecificEventTypes
};

/**
* Enumerates K32W061 platform-specific event types that are internal to the Weave Device Layer.
* Enumerates K32W061 platform-specific event types that are internal to the chip Device Layer.
*/
enum InternalPlatformSpecificEventTypes
{
Expand All @@ -63,7 +61,7 @@ enum InternalPlatformSpecificEventTypes
* Represents platform-specific event information for NXP K32W061 platforms.
*/

struct WeaveDevicePlatformEvent final
struct ChipDevicePlatformEvent final
{
union
{
Expand All @@ -72,7 +70,6 @@ struct WeaveDevicePlatformEvent final
};

} // namespace DeviceLayer
} // namespace Weave
} // namespace nl
} // namespace chip

#endif // WEAVE_DEVICE_PLATFORM_EVENT_H
#endif // CHIP_DEVICE_PLATFORM_EVENT_H
Loading