Skip to content

Commit

Permalink
Zap use byte span in struct (#6432)
Browse files Browse the repository at this point in the history
* [ZAP] Replace 'uint8_t *' by 'chip::ByteSpan' for OCTET_STRING

* Update gen/ folders
  • Loading branch information
vivien-apple authored and pull[bot] committed May 14, 2021
1 parent 3d9b6a5 commit 652a565
Show file tree
Hide file tree
Showing 20 changed files with 151 additions and 125 deletions.
21 changes: 11 additions & 10 deletions examples/all-clusters-app/all-clusters-common/gen/af-structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "enums.h"
#include <app/util/basic-types.h>
#include <stdint.h>
#include <support/Span.h>

// Struct for ApplicationLauncherApp
typedef struct _ApplicationLauncherApp
Expand Down Expand Up @@ -201,7 +202,7 @@ typedef struct _EventLogPayload
uint8_t logId;
uint16_t eventId;
uint32_t eventTime;
uint8_t * eventData;
chip::ByteSpan eventData;
} EmberAfEventLogPayload;

// Struct for ExtendedDiscoverAttributesInfoRecord
Expand All @@ -217,7 +218,7 @@ typedef struct _FabricDescriptor
{
chip::FabricId FabricId;
uint16_t VendorId;
uint8_t * Label;
chip::ByteSpan Label;
chip::NodeId NodeId;
} EmberAfFabricDescriptor;

Expand All @@ -237,8 +238,8 @@ typedef struct _GpTranslationTableUpdateTranslation
uint16_t profile;
uint16_t cluster;
uint8_t zigbeeCommandId;
uint8_t * zigbeeCommandPayload;
uint8_t * additionalInfoBlock;
chip::ByteSpan zigbeeCommandPayload;
chip::ByteSpan additionalInfoBlock;
} EmberAfGpTranslationTableUpdateTranslation;

// Struct for GroupInformationRecord
Expand All @@ -253,7 +254,7 @@ typedef struct _GroupKey
{
uint16_t VendorId;
uint16_t GroupKeyIndex;
uint8_t * GroupKeyRoot;
chip::ByteSpan GroupKeyRoot;
uint64_t GroupKeyEpochStartTime;
uint8_t GroupKeySecurityPolicy;
} EmberAfGroupKey;
Expand Down Expand Up @@ -487,20 +488,20 @@ typedef struct _SpecialDay
// Struct for ThreadInterfaceScanResult
typedef struct _ThreadInterfaceScanResult
{
uint8_t * DiscoveryResponse;
chip::ByteSpan DiscoveryResponse;
} EmberAfThreadInterfaceScanResult;

// Struct for TierLabelsPayload
typedef struct _TierLabelsPayload
{
uint8_t tierId;
uint8_t * tierLabel;
chip::ByteSpan tierLabel;
} EmberAfTierLabelsPayload;

// Struct for TopUpPayload
typedef struct _TopUpPayload
{
uint8_t * topUpCode;
chip::ByteSpan topUpCode;
int32_t topUpAmount;
uint32_t topUpTime;
} EmberAfTopUpPayload;
Expand Down Expand Up @@ -539,8 +540,8 @@ typedef struct _TvChannelLineupInfo
typedef struct _WiFiInterfaceScanResult
{
uint8_t Security;
uint8_t * SSID;
uint8_t * BSSID;
chip::ByteSpan SSID;
chip::ByteSpan BSSID;
uint8_t Channel;
uint32_t FrequencyBand;
} EmberAfWiFiInterfaceScanResult;
Expand Down
21 changes: 11 additions & 10 deletions examples/bridge-app/bridge-common/gen/af-structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "enums.h"
#include <app/util/basic-types.h>
#include <stdint.h>
#include <support/Span.h>

// Struct for ApplicationLauncherApp
typedef struct _ApplicationLauncherApp
Expand Down Expand Up @@ -201,7 +202,7 @@ typedef struct _EventLogPayload
uint8_t logId;
uint16_t eventId;
uint32_t eventTime;
uint8_t * eventData;
chip::ByteSpan eventData;
} EmberAfEventLogPayload;

// Struct for ExtendedDiscoverAttributesInfoRecord
Expand All @@ -217,7 +218,7 @@ typedef struct _FabricDescriptor
{
chip::FabricId FabricId;
uint16_t VendorId;
uint8_t * Label;
chip::ByteSpan Label;
chip::NodeId NodeId;
} EmberAfFabricDescriptor;

Expand All @@ -237,8 +238,8 @@ typedef struct _GpTranslationTableUpdateTranslation
uint16_t profile;
uint16_t cluster;
uint8_t zigbeeCommandId;
uint8_t * zigbeeCommandPayload;
uint8_t * additionalInfoBlock;
chip::ByteSpan zigbeeCommandPayload;
chip::ByteSpan additionalInfoBlock;
} EmberAfGpTranslationTableUpdateTranslation;

// Struct for GroupInformationRecord
Expand All @@ -253,7 +254,7 @@ typedef struct _GroupKey
{
uint16_t VendorId;
uint16_t GroupKeyIndex;
uint8_t * GroupKeyRoot;
chip::ByteSpan GroupKeyRoot;
uint64_t GroupKeyEpochStartTime;
uint8_t GroupKeySecurityPolicy;
} EmberAfGroupKey;
Expand Down Expand Up @@ -487,20 +488,20 @@ typedef struct _SpecialDay
// Struct for ThreadInterfaceScanResult
typedef struct _ThreadInterfaceScanResult
{
uint8_t * DiscoveryResponse;
chip::ByteSpan DiscoveryResponse;
} EmberAfThreadInterfaceScanResult;

// Struct for TierLabelsPayload
typedef struct _TierLabelsPayload
{
uint8_t tierId;
uint8_t * tierLabel;
chip::ByteSpan tierLabel;
} EmberAfTierLabelsPayload;

// Struct for TopUpPayload
typedef struct _TopUpPayload
{
uint8_t * topUpCode;
chip::ByteSpan topUpCode;
int32_t topUpAmount;
uint32_t topUpTime;
} EmberAfTopUpPayload;
Expand Down Expand Up @@ -539,8 +540,8 @@ typedef struct _TvChannelLineupInfo
typedef struct _WiFiInterfaceScanResult
{
uint8_t Security;
uint8_t * SSID;
uint8_t * BSSID;
chip::ByteSpan SSID;
chip::ByteSpan BSSID;
uint8_t Channel;
uint32_t FrequencyBand;
} EmberAfWiFiInterfaceScanResult;
Expand Down
4 changes: 2 additions & 2 deletions examples/chip-tool/gen/CHIPClientCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag
data[i].GroupKeyIndex = emberAfGetInt16u(message, 0, messageLen);
message += 2;
CHECK_MESSAGE_LENGTH(2);
data[i].GroupKeyRoot = emberAfGetString(message, 0, messageLen);
data[i].GroupKeyRoot = chip::ByteSpan(message, 16);
message += 16;
CHECK_MESSAGE_LENGTH(16);
data[i].GroupKeyEpochStartTime = emberAfGetInt64u(message, 0, messageLen);
Expand Down Expand Up @@ -490,7 +490,7 @@ bool emberAfReadAttributesResponseCallback(ClusterId clusterId, uint8_t * messag
data[i].VendorId = emberAfGetInt16u(message, 0, messageLen);
message += 2;
CHECK_MESSAGE_LENGTH(2);
data[i].Label = emberAfGetString(message, 0, messageLen);
data[i].Label = chip::ByteSpan(message, 32);
message += 32;
CHECK_MESSAGE_LENGTH(32);
data[i].NodeId = emberAfGetInt64u(message, 0, messageLen);
Expand Down
11 changes: 5 additions & 6 deletions examples/chip-tool/gen/CHIPClustersObjc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -2695,10 +2695,9 @@ static void CallbackFn(void * context, uint16_t count, _GroupKey * entries)
values[i] = [[NSDictionary alloc]
initWithObjectsAndKeys:[NSNumber numberWithUnsignedShort:entries[i].VendorId], @"VendorId",
[NSNumber numberWithUnsignedShort:entries[i].GroupKeyIndex], @"GroupKeyIndex",
[NSData dataWithBytes:entries[i].GroupKeyRoot + 1u length:emberAfStringLength(entries[i].GroupKeyRoot)],
@"GroupKeyRoot", [NSNumber numberWithUnsignedLongLong:entries[i].GroupKeyEpochStartTime],
@"GroupKeyEpochStartTime", [NSNumber numberWithUnsignedChar:entries[i].GroupKeySecurityPolicy],
@"GroupKeySecurityPolicy", nil];
[NSData dataWithBytes:entries[i].GroupKeyRoot.data() length:entries[i].GroupKeyRoot.size()], @"GroupKeyRoot",
[NSNumber numberWithUnsignedLongLong:entries[i].GroupKeyEpochStartTime], @"GroupKeyEpochStartTime",
[NSNumber numberWithUnsignedChar:entries[i].GroupKeySecurityPolicy], @"GroupKeySecurityPolicy", nil];
}

id array = [NSArray arrayWithObjects:values count:count];
Expand Down Expand Up @@ -2737,8 +2736,8 @@ static void CallbackFn(void * context, uint16_t count, _FabricDescriptor * entri
values[i] =
[[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedLongLong:entries[i].FabricId],
@"FabricId", [NSNumber numberWithUnsignedShort:entries[i].VendorId], @"VendorId",
[NSData dataWithBytes:entries[i].Label + 1u length:emberAfStringLength(entries[i].Label)],
@"Label", [NSNumber numberWithUnsignedLongLong:entries[i].NodeId], @"NodeId", nil];
[NSData dataWithBytes:entries[i].Label.data() length:entries[i].Label.size()], @"Label",
[NSNumber numberWithUnsignedLongLong:entries[i].NodeId], @"NodeId", nil];
}

id array = [NSArray arrayWithObjects:values count:count];
Expand Down
21 changes: 11 additions & 10 deletions examples/chip-tool/gen/af-structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "enums.h"
#include <app/util/basic-types.h>
#include <stdint.h>
#include <support/Span.h>

// Struct for ApplicationLauncherApp
typedef struct _ApplicationLauncherApp
Expand Down Expand Up @@ -201,7 +202,7 @@ typedef struct _EventLogPayload
uint8_t logId;
uint16_t eventId;
uint32_t eventTime;
uint8_t * eventData;
chip::ByteSpan eventData;
} EmberAfEventLogPayload;

// Struct for ExtendedDiscoverAttributesInfoRecord
Expand All @@ -217,7 +218,7 @@ typedef struct _FabricDescriptor
{
chip::FabricId FabricId;
uint16_t VendorId;
uint8_t * Label;
chip::ByteSpan Label;
chip::NodeId NodeId;
} EmberAfFabricDescriptor;

Expand All @@ -237,8 +238,8 @@ typedef struct _GpTranslationTableUpdateTranslation
uint16_t profile;
uint16_t cluster;
uint8_t zigbeeCommandId;
uint8_t * zigbeeCommandPayload;
uint8_t * additionalInfoBlock;
chip::ByteSpan zigbeeCommandPayload;
chip::ByteSpan additionalInfoBlock;
} EmberAfGpTranslationTableUpdateTranslation;

// Struct for GroupInformationRecord
Expand All @@ -253,7 +254,7 @@ typedef struct _GroupKey
{
uint16_t VendorId;
uint16_t GroupKeyIndex;
uint8_t * GroupKeyRoot;
chip::ByteSpan GroupKeyRoot;
uint64_t GroupKeyEpochStartTime;
uint8_t GroupKeySecurityPolicy;
} EmberAfGroupKey;
Expand Down Expand Up @@ -487,20 +488,20 @@ typedef struct _SpecialDay
// Struct for ThreadInterfaceScanResult
typedef struct _ThreadInterfaceScanResult
{
uint8_t * DiscoveryResponse;
chip::ByteSpan DiscoveryResponse;
} EmberAfThreadInterfaceScanResult;

// Struct for TierLabelsPayload
typedef struct _TierLabelsPayload
{
uint8_t tierId;
uint8_t * tierLabel;
chip::ByteSpan tierLabel;
} EmberAfTierLabelsPayload;

// Struct for TopUpPayload
typedef struct _TopUpPayload
{
uint8_t * topUpCode;
chip::ByteSpan topUpCode;
int32_t topUpAmount;
uint32_t topUpTime;
} EmberAfTopUpPayload;
Expand Down Expand Up @@ -539,8 +540,8 @@ typedef struct _TvChannelLineupInfo
typedef struct _WiFiInterfaceScanResult
{
uint8_t Security;
uint8_t * SSID;
uint8_t * BSSID;
chip::ByteSpan SSID;
chip::ByteSpan BSSID;
uint8_t Channel;
uint32_t FrequencyBand;
} EmberAfWiFiInterfaceScanResult;
Expand Down
21 changes: 11 additions & 10 deletions examples/lighting-app/lighting-common/gen/af-structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "enums.h"
#include <app/util/basic-types.h>
#include <stdint.h>
#include <support/Span.h>

// Struct for ApplicationLauncherApp
typedef struct _ApplicationLauncherApp
Expand Down Expand Up @@ -201,7 +202,7 @@ typedef struct _EventLogPayload
uint8_t logId;
uint16_t eventId;
uint32_t eventTime;
uint8_t * eventData;
chip::ByteSpan eventData;
} EmberAfEventLogPayload;

// Struct for ExtendedDiscoverAttributesInfoRecord
Expand All @@ -217,7 +218,7 @@ typedef struct _FabricDescriptor
{
chip::FabricId FabricId;
uint16_t VendorId;
uint8_t * Label;
chip::ByteSpan Label;
chip::NodeId NodeId;
} EmberAfFabricDescriptor;

Expand All @@ -237,8 +238,8 @@ typedef struct _GpTranslationTableUpdateTranslation
uint16_t profile;
uint16_t cluster;
uint8_t zigbeeCommandId;
uint8_t * zigbeeCommandPayload;
uint8_t * additionalInfoBlock;
chip::ByteSpan zigbeeCommandPayload;
chip::ByteSpan additionalInfoBlock;
} EmberAfGpTranslationTableUpdateTranslation;

// Struct for GroupInformationRecord
Expand All @@ -253,7 +254,7 @@ typedef struct _GroupKey
{
uint16_t VendorId;
uint16_t GroupKeyIndex;
uint8_t * GroupKeyRoot;
chip::ByteSpan GroupKeyRoot;
uint64_t GroupKeyEpochStartTime;
uint8_t GroupKeySecurityPolicy;
} EmberAfGroupKey;
Expand Down Expand Up @@ -487,20 +488,20 @@ typedef struct _SpecialDay
// Struct for ThreadInterfaceScanResult
typedef struct _ThreadInterfaceScanResult
{
uint8_t * DiscoveryResponse;
chip::ByteSpan DiscoveryResponse;
} EmberAfThreadInterfaceScanResult;

// Struct for TierLabelsPayload
typedef struct _TierLabelsPayload
{
uint8_t tierId;
uint8_t * tierLabel;
chip::ByteSpan tierLabel;
} EmberAfTierLabelsPayload;

// Struct for TopUpPayload
typedef struct _TopUpPayload
{
uint8_t * topUpCode;
chip::ByteSpan topUpCode;
int32_t topUpAmount;
uint32_t topUpTime;
} EmberAfTopUpPayload;
Expand Down Expand Up @@ -539,8 +540,8 @@ typedef struct _TvChannelLineupInfo
typedef struct _WiFiInterfaceScanResult
{
uint8_t Security;
uint8_t * SSID;
uint8_t * BSSID;
chip::ByteSpan SSID;
chip::ByteSpan BSSID;
uint8_t Channel;
uint32_t FrequencyBand;
} EmberAfWiFiInterfaceScanResult;
Expand Down
Loading

0 comments on commit 652a565

Please sign in to comment.