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

Fixes for building nRF5 platform #104

Merged
merged 6 commits into from
Mar 25, 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
4 changes: 3 additions & 1 deletion src/ble/CHIPBleServiceData.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
#ifndef CHIP_BLE_SERVICE_DATA_H
#define CHIP_BLE_SERVICE_DATA_H

#include <core/CHIPEncoding.h>

namespace chip {
namespace Ble {

Expand All @@ -41,7 +43,7 @@ enum chipBLEServiceDataType
* Defines the over-the-air encoded format of the device identification information block that appears
* within chip BLE service advertisement data.
*/
struct chipBLEDeviceIdentificationInfo
struct ChipBLEDeviceIdentificationInfo
{
enum
{
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/CHIPDeviceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@
* using the chip Time Sync protocol.
*/
#ifndef CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC
#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 1
#define CHIP_DEVICE_CONFIG_ENABLE_CHIP_TIME_SERVICE_TIME_SYNC 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ToDo: File issue to track this

#endif

/**
Expand Down
5 changes: 3 additions & 2 deletions src/include/platform/CHIPDeviceEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ typedef void (*AsyncWorkFunct)(intptr_t arg);
#include CHIPDEVICEPLATFORMEVENT_HEADER
#endif

#include <system/SystemPacketBuffer.h>

namespace chip {
namespace DeviceLayer {

Expand Down Expand Up @@ -353,7 +355,6 @@ struct ChipDeviceEvent final
uint64_t PeerNodeId;
uint16_t SessionKeyId;
uint8_t EncType;
::chip::ChipAuthMode AuthMode;
bool IsCommissioner;
} SessionEstablished;
struct
Expand All @@ -367,7 +368,7 @@ struct ChipDeviceEvent final
struct
{
BLE_CONNECTION_OBJECT ConId;
PacketBuffer * Data;
chip::System::PacketBuffer * Data;
} CHIPoBLEWriteReceived;
struct
{
Expand Down
41 changes: 7 additions & 34 deletions src/include/platform/ConfigurationManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#define CONFIGURATION_MANAGER_H

#include <platform/PersistedStorage.h>
#include <profiles/device-description/DeviceDescription.h>
#include <profiles/network-provisioning/NetworkProvisioning.h>

namespace chip {
namespace Ble {
Expand All @@ -38,29 +36,24 @@ namespace DeviceLayer {

class PlatformManagerImpl;
class ConfigurationManagerImpl;
class TraitManager;
namespace Internal {
template<class> class GenericPlatformManagerImpl;
class DeviceControlServer;
class NetworkProvisioningServer;
}

/**
* Provides access to runtime and build-time configuration information for a chip device.
*/
class ConfigurationManager
{
using ChipDeviceDescriptor = ::chip::Profiles::DeviceDescription::ChipDeviceDescriptor;

public:

// ===== Members that define the public interface of the ConfigurationManager

enum
{
kMaxPairingCodeLength = 15,
kMaxSerialNumberLength = ChipDeviceDescriptor::kMaxSerialNumberLength,
kMaxFirmwareRevisionLength = ChipDeviceDescriptor::kMaxSoftwareVersionLength,
kMaxSerialNumberLength = 32,
Copy link
Contributor

Choose a reason for hiding this comment

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

Tag these with an XXX or some such for follow-up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ToDo: File issue to track this

kMaxFirmwareRevisionLength = 32,
Copy link
Contributor

Choose a reason for hiding this comment

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

Tag these with an XXX or some such for follow-up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gerickson I am going to submit GitHub issues to track these.

};

CHIP_ERROR GetVendorId(uint16_t & vendorId);
Expand Down Expand Up @@ -109,8 +102,6 @@ class ConfigurationManager
CHIP_ERROR StoreServiceConfig(const uint8_t * serviceConfig, size_t serviceConfigLen);
CHIP_ERROR StorePairedAccountId(const char * accountId, size_t accountIdLen);

CHIP_ERROR GetDeviceDescriptor(ChipDeviceDescriptor & deviceDesc);
CHIP_ERROR GetDeviceDescriptorTLV(uint8_t * buf, size_t bufSize, size_t & encodedLen);
CHIP_ERROR GetQRCodeString(char * buf, size_t bufSize);

CHIP_ERROR GetWiFiAPSSID(char * buf, size_t bufSize);
Expand All @@ -135,17 +126,14 @@ class ConfigurationManager

friend class ::chip::DeviceLayer::PlatformManagerImpl;
template<class> friend class ::chip::DeviceLayer::Internal::GenericPlatformManagerImpl;
friend class ::chip::DeviceLayer::TraitManager;
friend class ::chip::DeviceLayer::Internal::DeviceControlServer;
// Parentheses used to fix clang parsing issue with these declarations
friend CHIP_ERROR (::chip::Platform::PersistedStorage::Read(::chip::Platform::PersistedStorage::Key key, uint32_t & value));
friend CHIP_ERROR (::chip::Platform::PersistedStorage::Write(::chip::Platform::PersistedStorage::Key key, uint32_t value));
friend CHIP_ERROR ::chip::Platform::PersistedStorage::Read(::chip::Platform::PersistedStorage::Key key, uint32_t & value);
friend CHIP_ERROR ::chip::Platform::PersistedStorage::Write(::chip::Platform::PersistedStorage::Key key, uint32_t value);

using ImplClass = ConfigurationManagerImpl;

CHIP_ERROR Init();
CHIP_ERROR ConfigureChipStack();
::chip::Profiles::Security::AppKeys::GroupKeyStoreBase * GetGroupKeyStore();
bool CanFactoryReset();
CHIP_ERROR GetFailSafeArmed(bool & val);
CHIP_ERROR SetFailSafeArmed(bool val);
Expand Down Expand Up @@ -429,16 +417,6 @@ inline CHIP_ERROR ConfigurationManager::WritePersistedStorageValue(::chip::Platf
return static_cast<ImplClass*>(this)->_WritePersistedStorageValue(key, value);
}

inline CHIP_ERROR ConfigurationManager::GetDeviceDescriptor(chipDeviceDescriptor & deviceDesc)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ToDo: File issue to track this

{
return static_cast<ImplClass*>(this)->_GetDeviceDescriptor(deviceDesc);
}

inline CHIP_ERROR ConfigurationManager::GetDeviceDescriptorTLV(uint8_t * buf, size_t bufSize, size_t & encodedLen)
{
return static_cast<ImplClass*>(this)->_GetDeviceDescriptorTLV(buf, bufSize, encodedLen);
}

inline CHIP_ERROR ConfigurationManager::GetQRCodeString(char * buf, size_t bufSize)
{
return static_cast<ImplClass*>(this)->_GetQRCodeString(buf, bufSize);
Expand All @@ -449,7 +427,7 @@ inline CHIP_ERROR ConfigurationManager::GetWiFiAPSSID(char * buf, size_t bufSize
return static_cast<ImplClass*>(this)->_GetWiFiAPSSID(buf, bufSize);
}

inline CHIP_ERROR ConfigurationManager::GetBLEDeviceIdentificationInfo(Ble::chipBLEDeviceIdentificationInfo & deviceIdInfo)
inline CHIP_ERROR ConfigurationManager::GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo)
{
return static_cast<ImplClass*>(this)->_GetBLEDeviceIdentificationInfo(deviceIdInfo);
}
Expand Down Expand Up @@ -489,14 +467,9 @@ inline CHIP_ERROR ConfigurationManager::Init()
return static_cast<ImplClass*>(this)->_Init();
}

inline CHIP_ERROR ConfigurationManager::ConfigurechipStack()
{
return static_cast<ImplClass*>(this)->_ConfigurechipStack();
}

inline ::chip::Profiles::Security::AppKeys::GroupKeyStoreBase * ConfigurationManager::GetGroupKeyStore()
inline CHIP_ERROR ConfigurationManager::ConfigureChipStack()
{
return static_cast<ImplClass*>(this)->_GetGroupKeyStore();
return static_cast<ImplClass*>(this)->_ConfigureChipStack();
}

inline bool ConfigurationManager::CanFactoryReset()
Expand Down
1 change: 0 additions & 1 deletion src/include/platform/EFR32/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class ConfigurationManagerImpl final : public ConfigurationManager,

CHIP_ERROR _Init(void);
CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t *buf);
CHIP_ERROR _GetDeviceDescriptor(::chip::Profiles::DeviceDescription::ChipDeviceDescriptor &deviceDesc);
::chip::Profiles::Security::AppKeys::GroupKeyStoreBase *_GetGroupKeyStore(void);
bool _CanFactoryReset(void);
void _InitiateFactoryReset(void);
Expand Down
6 changes: 4 additions & 2 deletions src/include/platform/GeneralUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
* General utility functions available on all platforms.
*/

#include <inet/inet.h>

namespace chip {
namespace DeviceLayer {

extern CHIP_ERROR ParseCompilerDateStr(const char * dateStr, uint16_t & year, uint8_t & month, uint8_t & dayOfMonth);
extern CHIP_ERROR Parse24HourTimeStr(const char * timeStr, uint8_t & hour, uint8_t & minute, uint8_t & second);
extern const char * CharacterizeIPv6Address(const ::Inet::IPAddress & ipAddr);
extern const char * CharacterizeIPv6Prefix(const Inet::IPPrefix & inPrefix);
extern const char * CharacterizeIPv6Address(const chip::Inet::IPAddress &ipAddr);
extern const char * CharacterizeIPv6Prefix(const chip::Inet::IPPrefix &inPrefix);
extern void RegisterDeviceLayerErrorFormatter(void);
extern bool FormatDeviceLayerError(char * buf, uint16_t bufSize, int32_t err);

Expand Down
32 changes: 16 additions & 16 deletions src/include/platform/PlatformManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ class PlatformManager
template<class> friend class Internal::GenericThreadStackManagerImpl_OpenThread_LwIP;
template<class> friend class Internal::GenericConfigurationManagerImpl;
// Parentheses used to fix clang parsing issue with these declarations
friend ::chip::System::Error (::chip::System::Platform::Layer::PostEvent(::chip::System::Layer & aLayer, void * aContext, ::chip::System::Object & aTarget, ::chip::System::EventType aType, uintptr_t aArgument));
friend ::chip::System::Error (::chip::System::Platform::Layer::DispatchEvents(::chip::System::Layer & aLayer, void * aContext));
friend ::chip::System::Error (::chip::System::Platform::Layer::DispatchEvent(::chip::System::Layer & aLayer, void * aContext, ::chip::System::Event aEvent));
friend ::chip::System::Error (::chip::System::Platform::Layer::StartTimer(::chip::System::Layer & aLayer, void * aContext, uint32_t aMilliseconds));
friend ::chip::System::Error ::chip::System::Platform::Layer::PostEvent(::chip::System::Layer & aLayer, void * aContext, ::chip::System::Object & aTarget, ::chip::System::EventType aType, uintptr_t aArgument);
friend ::chip::System::Error ::chip::System::Platform::Layer::DispatchEvents(::chip::System::Layer & aLayer, void * aContext);
friend ::chip::System::Error ::chip::System::Platform::Layer::DispatchEvent(::chip::System::Layer & aLayer, void * aContext, ::chip::System::Event aEvent);
friend ::chip::System::Error ::chip::System::Platform::Layer::StartTimer(::chip::System::Layer & aLayer, void * aContext, uint32_t aMilliseconds);

void PostEvent(const ChipDeviceEvent * event);
void DispatchEvent(const ChipDeviceEvent * event);
Expand Down Expand Up @@ -155,9 +155,9 @@ extern PlatformManagerImpl & PlatformMgrImpl(void);
namespace chip {
namespace DeviceLayer {

inline CHIP_ERROR PlatformManager::InitchipStack()
inline CHIP_ERROR PlatformManager::InitChipStack()
{
return static_cast<ImplClass*>(this)->_InitchipStack();
return static_cast<ImplClass*>(this)->_InitChipStack();
}

inline CHIP_ERROR PlatformManager::AddEventHandler(EventHandlerFunct handler, intptr_t arg)
Expand Down Expand Up @@ -185,34 +185,34 @@ inline CHIP_ERROR PlatformManager::StartEventLoopTask(void)
return static_cast<ImplClass*>(this)->_StartEventLoopTask();
}

inline void PlatformManager::LockchipStack(void)
inline void PlatformManager::LockChipStack(void)
{
static_cast<ImplClass*>(this)->_LockchipStack();
static_cast<ImplClass*>(this)->_LockChipStack();
}

inline bool PlatformManager::TryLockchipStack(void)
inline bool PlatformManager::TryLockChipStack(void)
{
return static_cast<ImplClass*>(this)->_TryLockchipStack();
return static_cast<ImplClass*>(this)->_TryLockChipStack();
}

inline void PlatformManager::UnlockchipStack(void)
inline void PlatformManager::UnlockChipStack(void)
{
static_cast<ImplClass*>(this)->_UnlockchipStack();
static_cast<ImplClass*>(this)->_UnlockChipStack();
}

inline void PlatformManager::PostEvent(const chipDeviceEvent * event)
inline void PlatformManager::PostEvent(const ChipDeviceEvent * event)
{
static_cast<ImplClass*>(this)->_PostEvent(event);
}

inline void PlatformManager::DispatchEvent(const chipDeviceEvent * event)
inline void PlatformManager::DispatchEvent(const ChipDeviceEvent * event)
{
static_cast<ImplClass*>(this)->_DispatchEvent(event);
}

inline CHIP_ERROR PlatformManager::StartchipTimer(uint32_t durationMS)
inline CHIP_ERROR PlatformManager::StartChipTimer(uint32_t durationMS)
{
return static_cast<ImplClass*>(this)->_StartchipTimer(durationMS);
return static_cast<ImplClass*>(this)->_StartChipTimer(durationMS);
}

} // namespace DeviceLayer
Expand Down
14 changes: 5 additions & 9 deletions src/include/platform/SoftwareUpdateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,18 @@

#if CHIP_DEVICE_CONFIG_ENABLE_SOFTWARE_UPDATE_MANAGER

#include <profiles/software-update/SoftwareUpdateProfile.h>
#include <platform/internal/CHIPDeviceLayerInternal.h>
#include <core/CHIPTLV.h>

namespace chip {
namespace DeviceLayer {

using namespace chip::TLV;

class SoftwareUpdateManagerImpl;

class SoftwareUpdateManager
{
typedef ::chip::TLV::TLVWriter TLVWriter;
typedef ::chip::Profiles::SoftwareUpdate::UpdatePriority UpdatePriority;
typedef ::chip::Profiles::SoftwareUpdate::UpdateCondition UpdateCondition;

using ImplClass = SoftwareUpdateManagerImpl;


Expand Down Expand Up @@ -363,6 +361,8 @@ extern SoftwareUpdateManagerImpl & SoftwareUpdateMgrImpl(void);
namespace chip {
namespace DeviceLayer {

using namespace chip::TLV;

union SoftwareUpdateManager::InEventParam
{
void Clear(void) { memset(this, 0, sizeof(*this)); }
Expand All @@ -376,13 +376,10 @@ union SoftwareUpdateManager::InEventParam
struct
{
CHIP_ERROR Error;
Profiles::StatusReporting::StatusReport *StatusReport;
} QueryPrepareFailed;

struct
{
UpdatePriority Priority;
UpdateCondition Condition;
uint8_t IntegrityType;
const char *URI;
const char *Version;
Expand Down Expand Up @@ -415,7 +412,6 @@ union SoftwareUpdateManager::InEventParam
struct
{
CHIP_ERROR Error;
Profiles::StatusReporting::StatusReport *StatusReport;
} Finished;
};

Expand Down
8 changes: 1 addition & 7 deletions src/include/platform/SoftwareUpdateManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#if CHIP_DEVICE_CONFIG_ENABLE_SOFTWARE_UPDATE_MANAGER

#include <platform/internal/GenericSoftwareUpdateManagerImpl.h>
#include <platform/internal/GenericSoftwareUpdateManagerImpl_BDX.h>

namespace chip {
namespace DeviceLayer {
Expand All @@ -32,8 +31,7 @@ namespace DeviceLayer {
*/
class SoftwareUpdateManagerImpl final
: public SoftwareUpdateManager,
public Internal::GenericSoftwareUpdateManagerImpl<SoftwareUpdateManagerImpl>,
public Internal::GenericSoftwareUpdateManagerImpl_BDX<SoftwareUpdateManagerImpl>
public Internal::GenericSoftwareUpdateManagerImpl<SoftwareUpdateManagerImpl>
{
// Allow the SoftwareUpdateManager interface class to delegate method calls to
// the implementation methods provided by this class.
Expand All @@ -43,10 +41,6 @@ class SoftwareUpdateManagerImpl final
// and types defined on this class.
friend class Internal::GenericSoftwareUpdateManagerImpl<SoftwareUpdateManagerImpl>;

// Allow the GenericSoftwareUpdateManagerImpl_BDX base class to access helper methods
// and types defined on this class.
friend class Internal::GenericSoftwareUpdateManagerImpl_BDX<SoftwareUpdateManagerImpl>;

public:

// ===== Members for internal use by the following friends.
Expand Down
4 changes: 2 additions & 2 deletions src/include/platform/internal/BLEManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class BLEManager
CHIP_ERROR SetDeviceName(const char * deviceName);
uint16_t NumConnections(void);
void OnPlatformEvent(const ChipDeviceEvent * event);
::Ble::BleLayer * GetBleLayer(void) const;
chip::Ble::BleLayer * GetBleLayer(void) const;

protected:

Expand Down Expand Up @@ -170,7 +170,7 @@ inline void BLEManager::OnPlatformEvent(const ChipDeviceEvent * event)
static_cast<ImplClass*>(this)->_OnPlatformEvent(event);
}

inline ::Ble::BleLayer * BLEManager::GetBleLayer(void) const
inline BleLayer * BLEManager::GetBleLayer(void) const
{
return static_cast<const ImplClass*>(this)->_GetBleLayer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ class GenericConfigurationManagerImpl
CHIP_ERROR _ClearServiceProvisioningData();
CHIP_ERROR _GetFailSafeArmed(bool & val);
CHIP_ERROR _SetFailSafeArmed(bool val);
CHIP_ERROR _GetDeviceDescriptor(::chip::Profiles::DeviceDescription::ChipeviceDescriptor & deviceDesc);
CHIP_ERROR _GetDeviceDescriptorTLV(uint8_t * buf, size_t bufSize, size_t & encodedLen);
CHIP_ERROR _GetQRCodeString(char * buf, size_t bufSize);
CHIP_ERROR _GetWiFiAPSSID(char * buf, size_t bufSize);
CHIP_ERROR _GetBLEDeviceIdentificationInfo(Ble::ChipBLEDeviceIdentificationInfo & deviceIdInfo);
CHIP_ERROR _ConfigureChipStack();
bool _IsServiceProvisioned();
bool _IsMemberOfFabric();
bool _IsPairedToAccount();
Expand Down Expand Up @@ -131,8 +130,6 @@ class GenericConfigurationManagerImpl

ImplClass * Impl() { return static_cast<ImplClass *>(this); }

static void HashLengthAndBase64Value(Platform::Security::SHA256 & hash, const uint8_t * val, uint16_t valLen);

#if CHIP_DEVICE_CONFIG_ENABLE_JUST_IN_TIME_PROVISIONING
bool UseManufacturerCredentialsAsOperational();
#endif
Expand Down
Loading