Skip to content

Commit

Permalink
(Temporary) OTA: change protocolsSupported to single value instead of…
Browse files Browse the repository at this point in the history
… list (#8632)

* change protocolsSupported to single value instead of list

* generate missing zap file
  • Loading branch information
holbrookt authored and pull[bot] committed Aug 16, 2021
1 parent d4b7b50 commit 3966291
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5758,7 +5758,7 @@ void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aComman
uint16_t imageType;
uint16_t hardwareVersion;
uint32_t currentVersion;
/* TYPE WARNING: array array defaults to */ uint8_t * protocolsSupported;
uint8_t protocolsSupported;
const uint8_t * location;
uint8_t requestorCanConsent;
chip::ByteSpan metadataForProvider;
Expand Down Expand Up @@ -5807,8 +5807,7 @@ void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aComman
TLVUnpackError = aDataTlv.Get(currentVersion);
break;
case 5:
// Just for compatibility, we will add array type support in IM later.
TLVUnpackError = aDataTlv.GetDataPtr(const_cast<const uint8_t *&>(protocolsSupported));
TLVUnpackError = aDataTlv.Get(protocolsSupported);
break;
case 6:
// TODO(#5542): The cluster handlers should accept a ByteSpan for all string types.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5326,7 +5326,7 @@ void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aComman
uint16_t imageType;
uint16_t hardwareVersion;
uint32_t currentVersion;
/* TYPE WARNING: array array defaults to */ uint8_t * protocolsSupported;
uint8_t protocolsSupported;
const uint8_t * location;
uint8_t requestorCanConsent;
chip::ByteSpan metadataForProvider;
Expand Down Expand Up @@ -5375,8 +5375,7 @@ void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aComman
TLVUnpackError = aDataTlv.Get(currentVersion);
break;
case 5:
// Just for compatibility, we will add array type support in IM later.
TLVUnpackError = aDataTlv.GetDataPtr(const_cast<const uint8_t *&>(protocolsSupported));
TLVUnpackError = aDataTlv.Get(protocolsSupported);
break;
case 6:
// TODO(#5542): The cluster handlers should accept a ByteSpan for all string types.
Expand Down
5 changes: 2 additions & 3 deletions examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3464,7 +3464,7 @@ void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aComman
uint16_t imageType;
uint16_t hardwareVersion;
uint32_t currentVersion;
/* TYPE WARNING: array array defaults to */ uint8_t * protocolsSupported;
uint8_t protocolsSupported;
const uint8_t * location;
uint8_t requestorCanConsent;
chip::ByteSpan metadataForProvider;
Expand Down Expand Up @@ -3513,8 +3513,7 @@ void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aComman
TLVUnpackError = aDataTlv.Get(currentVersion);
break;
case 5:
// Just for compatibility, we will add array type support in IM later.
TLVUnpackError = aDataTlv.GetDataPtr(const_cast<const uint8_t *&>(protocolsSupported));
TLVUnpackError = aDataTlv.Get(protocolsSupported);
break;
case 6:
// TODO(#5542): The cluster handlers should accept a ByteSpan for all string types.
Expand Down
4 changes: 2 additions & 2 deletions src/app/clusters/ota-provider/ota-provider-delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ namespace clusters {
class OTAProviderDelegate
{
public:
// TODO: protocolsSupported should be list of OTADownloadProtocol enums, not uint8_t*
// TODO(#8605): protocolsSupported should be list of OTADownloadProtocol enums, not uint8_t
virtual EmberAfStatus HandleQueryImage(uint16_t vendorId, uint16_t productId, uint16_t imageType, uint16_t hardwareVersion,
uint32_t currentVersion, uint8_t * protocolsSupported, const chip::ByteSpan & location,
uint32_t currentVersion, uint8_t protocolsSupported, const chip::ByteSpan & location,
bool clientCanConsent, const chip::ByteSpan & metadataForProvider) = 0;

virtual EmberAfStatus HandleApplyUpdateRequest(const chip::ByteSpan & updateToken, uint32_t newVersion) = 0;
Expand Down
36 changes: 17 additions & 19 deletions src/app/clusters/ota-provider/ota-provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ OTAProviderDelegate * GetDelegate(chip::EndpointId endpoint)
return (ep == 0xFFFF ? NULL : gDelegateTable[ep]);
}

bool SendStatusIfDelegateNull(chip::EndpointId endpointId)
bool SendStatusIfDelegateNull(chip::EndpointId endpoint)
{
if (GetDelegate(endpointId) == nullptr)
if (GetDelegate(endpoint) == nullptr)
{
ChipLogError(Zcl, "No OTAProviderDelegate set for ep:%" PRIu16, endpointId);
ChipLogError(Zcl, "No OTAProviderDelegate set for ep:%" PRIu16, endpoint);
emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_UNSUP_COMMAND);
return true;
}
Expand All @@ -72,12 +72,11 @@ bool emberAfOtaSoftwareUpdateProviderClusterApplyUpdateRequestCallback(chip::End
chip::ByteSpan updateToken, uint32_t newVersion)
{
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
chip::EndpointId endpointId = emberAfCurrentEndpoint();
OTAProviderDelegate * delegate = GetDelegate(endpointId);
OTAProviderDelegate * delegate = GetDelegate(endpoint);

ChipLogDetail(Zcl, "OTA Provider received ApplyUpdateRequest");

if (SendStatusIfDelegateNull(endpointId))
if (SendStatusIfDelegateNull(endpoint))
{
return true;
}
Expand Down Expand Up @@ -111,12 +110,11 @@ bool emberAfOtaSoftwareUpdateProviderClusterNotifyUpdateAppliedCallback(chip::En
chip::ByteSpan updateToken, uint32_t currentVersion)
{
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
chip::EndpointId endpointId = emberAfCurrentEndpoint();
OTAProviderDelegate * delegate = GetDelegate(endpointId);
OTAProviderDelegate * delegate = GetDelegate(endpoint);

ChipLogDetail(Zcl, "OTA Provider received NotifyUpdateUpplied");

if (SendStatusIfDelegateNull(endpointId))
if (SendStatusIfDelegateNull(endpoint))
{
return true;
}
Expand Down Expand Up @@ -153,17 +151,17 @@ bool emberAfOtaSoftwareUpdateProviderClusterNotifyUpdateAppliedCallback(chip::En
* @param metadataForProvider Optional, max 512 octets. A TLV-encoded Vendor-specific payload.
*/

bool emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(
chip::EndpointId endpoint, chip::app::CommandHandler * commandObj, uint16_t vendorId, uint16_t productId, uint16_t imageType,
uint16_t hardwareVersion, uint32_t currentVersion,
/* TYPE WARNING: array array defaults to */ uint8_t * protocolsSupported, uint8_t * location, uint8_t clientCanConsent,
chip::ByteSpan metadataForProvider)
bool emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(chip::EndpointId endpoint, chip::app::CommandHandler * commandObj,
uint16_t vendorId, uint16_t productId, uint16_t imageType,
uint16_t hardwareVersion, uint32_t currentVersion,
/* TODO(#8605): change this to list */ uint8_t protocolsSupported,
uint8_t * location, uint8_t clientCanConsent,
chip::ByteSpan metadataForProvider)
{
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
chip::EndpointId endpointId = emberAfCurrentEndpoint();
OTAProviderDelegate * delegate = GetDelegate(endpointId);
OTAProviderDelegate * delegate = GetDelegate(endpoint);

if (SendStatusIfDelegateNull(endpointId))
if (SendStatusIfDelegateNull(endpoint))
{
return true;
};
Expand Down Expand Up @@ -199,9 +197,9 @@ namespace chip {
namespace app {
namespace clusters {

void OTAProvider::SetDelegate(chip::EndpointId endpointId, OTAProviderDelegate * delegate)
void OTAProvider::SetDelegate(chip::EndpointId endpoint, OTAProviderDelegate * delegate)
{
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpointId, ZCL_OTA_PROVIDER_CLUSTER_ID);
uint16_t ep = emberAfFindClusterServerEndpointIndex(endpoint, ZCL_OTA_PROVIDER_CLUSTER_ID);
if (ep != 0xFFFF)
{
gDelegateTable[ep] = delegate;
Expand Down
9 changes: 5 additions & 4 deletions src/app/common/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -15727,10 +15727,11 @@ bool emberAfBasicClusterLeaveCallback(chip::EndpointId endpoint, chip::app::Comm
/**
* @brief Cluster QueryImage Command callback (from client)
*/
bool emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(
chip::EndpointId endpoint, chip::app::CommandHandler * commandObj, uint16_t vendorId, uint16_t productId, uint16_t imageType,
uint16_t hardwareVersion, uint32_t currentVersion, /* TYPE WARNING: array array defaults to */ uint8_t * protocolsSupported,
uint8_t * location, uint8_t requestorCanConsent, chip::ByteSpan metadataForProvider);
bool emberAfOtaSoftwareUpdateProviderClusterQueryImageCallback(chip::EndpointId endpoint, chip::app::CommandHandler * commandObj,
uint16_t vendorId, uint16_t productId, uint16_t imageType,
uint16_t hardwareVersion, uint32_t currentVersion,
uint8_t protocolsSupported, uint8_t * location,
uint8_t requestorCanConsent, chip::ByteSpan metadataForProvider);
/**
* @brief Cluster ApplyUpdateRequest Command callback (from client)
*/
Expand Down
10 changes: 4 additions & 6 deletions src/app/common/gen/client-command-macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -1736,20 +1736,18 @@
* @param imageType INT16U
* @param hardwareVersion INT16U
* @param currentVersion INT32U
* @param protocolsSupported OTADownloadProtocol []
* @param protocolsSupportedLen int
* @param protocolsSupported OTADownloadProtocol
* @param location CHAR_STRING
* @param requestorCanConsent BOOLEAN
* @param metadataForProvider OCTET_STRING
*/
#define emberAfFillCommandOTA \
Software Update ProviderClusterQueryImage(vendorId, productId, imageType, hardwareVersion, currentVersion, protocolsSupported, \
protocolsSupportedLen, location, requestorCanConsent, metadataForProvider) \
location, requestorCanConsent, metadataForProvider) \
emberAfFillExternalBuffer(mask, \
\
ZCL_QUERY_IMAGE_COMMAND_ID, "uuuuubuuu", vendorId, productId, imageType, hardwareVersion, \
currentVersion, protocolsSupported, protocolsSupportedLen, location, requestorCanConsent, \
metadataForProvider);
ZCL_QUERY_IMAGE_COMMAND_ID, "uuuuuuuuu", vendorId, productId, imageType, hardwareVersion, \
currentVersion, protocolsSupported, location, requestorCanConsent, metadataForProvider);

/** @brief Command description for ApplyUpdateRequest
*
Expand Down
2 changes: 1 addition & 1 deletion src/app/zap-templates/zcl/data-model/chip/chip-ota.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ limitations under the License.
<arg name="imageType" type="INT16U"/>
<arg name="hardwareVersion" type="INT16U"/>
<arg name="currentVersion" type="INT32U"/>
<arg name="protocolsSupported" type="OTADownloadProtocol" array="true"/>
<arg name="protocolsSupported" type="OTADownloadProtocol"/> <!-- TODO(#8605): add array="true" when lists are supported -->
<arg name="location" type="CHAR_STRING" length="2"/>
<arg name="requestorCanConsent" type="BOOLEAN"/>
<arg name="metadataForProvider" type="OCTET_STRING" length="512"/>
Expand Down

0 comments on commit 3966291

Please sign in to comment.