Skip to content

Commit

Permalink
Fix ble connection in Temperature Measurement app
Browse files Browse the repository at this point in the history
  • Loading branch information
“sonalipatil” committed Jun 17, 2021
1 parent c3443e0 commit 5cb5206
Show file tree
Hide file tree
Showing 6 changed files with 3,056 additions and 296 deletions.
180 changes: 180 additions & 0 deletions examples/temperature-measurement-app/esp32/main/gen/attribute-size.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,161 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo
}
break;
}
case 0x0035: // Thread Network Diagnostics Cluster
{
uint16_t entryOffset = kSizeLengthInBytes;
switch (am->attributeId)
{
case 0x0007: // NeighborTableList
{
entryLength = 31;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _NeighborTable
_NeighborTable * entry = reinterpret_cast<_NeighborTable *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write,
&entryOffset, sizeof(entry->ExtAddress)); // INT64U
copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset,
sizeof(entry->Age)); // INT32U
copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset,
sizeof(entry->Rloc16)); // INT16U
copyListMember(write ? dest : (uint8_t *) &entry->LinkFrameCounter, write ? (uint8_t *) &entry->LinkFrameCounter : src,
write, &entryOffset, sizeof(entry->LinkFrameCounter)); // INT32U
copyListMember(write ? dest : (uint8_t *) &entry->MleFrameCounter, write ? (uint8_t *) &entry->MleFrameCounter : src,
write, &entryOffset, sizeof(entry->MleFrameCounter)); // INT32U
copyListMember(write ? dest : (uint8_t *) &entry->LQI, write ? (uint8_t *) &entry->LQI : src, write, &entryOffset,
sizeof(entry->LQI)); // INT8U
copyListMember(write ? dest : (uint8_t *) &entry->AverageRssi, write ? (uint8_t *) &entry->AverageRssi : src, write,
&entryOffset, sizeof(entry->AverageRssi)); // INT8S
copyListMember(write ? dest : (uint8_t *) &entry->LastRssi, write ? (uint8_t *) &entry->LastRssi : src, write,
&entryOffset, sizeof(entry->LastRssi)); // INT8S
copyListMember(write ? dest : (uint8_t *) &entry->FrameErrorRate, write ? (uint8_t *) &entry->FrameErrorRate : src,
write, &entryOffset, sizeof(entry->FrameErrorRate)); // INT8U
copyListMember(write ? dest : (uint8_t *) &entry->MessageErrorRate, write ? (uint8_t *) &entry->MessageErrorRate : src,
write, &entryOffset, sizeof(entry->MessageErrorRate)); // INT8U
copyListMember(write ? dest : (uint8_t *) &entry->RxOnWhenIdle, write ? (uint8_t *) &entry->RxOnWhenIdle : src, write,
&entryOffset, sizeof(entry->RxOnWhenIdle)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->FullThreadDevice, write ? (uint8_t *) &entry->FullThreadDevice : src,
write, &entryOffset, sizeof(entry->FullThreadDevice)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->FullNetworkData, write ? (uint8_t *) &entry->FullNetworkData : src,
write, &entryOffset, sizeof(entry->FullNetworkData)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->IsChild, write ? (uint8_t *) &entry->IsChild : src, write,
&entryOffset, sizeof(entry->IsChild)); // BOOLEAN
break;
}
case 0x0008: // RouteTableList
{
entryLength = 18;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _RouteTable
_RouteTable * entry = reinterpret_cast<_RouteTable *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *) &entry->ExtAddress, write ? (uint8_t *) &entry->ExtAddress : src, write,
&entryOffset, sizeof(entry->ExtAddress)); // INT64U
copyListMember(write ? dest : (uint8_t *) &entry->Rloc16, write ? (uint8_t *) &entry->Rloc16 : src, write, &entryOffset,
sizeof(entry->Rloc16)); // INT16U
copyListMember(write ? dest : (uint8_t *) &entry->RouterId, write ? (uint8_t *) &entry->RouterId : src, write,
&entryOffset, sizeof(entry->RouterId)); // INT8U
copyListMember(write ? dest : (uint8_t *) &entry->NextHop, write ? (uint8_t *) &entry->NextHop : src, write,
&entryOffset, sizeof(entry->NextHop)); // INT8U
copyListMember(write ? dest : (uint8_t *) &entry->PathCost, write ? (uint8_t *) &entry->PathCost : src, write,
&entryOffset, sizeof(entry->PathCost)); // INT8U
copyListMember(write ? dest : (uint8_t *) &entry->LQIIn, write ? (uint8_t *) &entry->LQIIn : src, write, &entryOffset,
sizeof(entry->LQIIn)); // INT8U
copyListMember(write ? dest : (uint8_t *) &entry->LQIOut, write ? (uint8_t *) &entry->LQIOut : src, write, &entryOffset,
sizeof(entry->LQIOut)); // INT8U
copyListMember(write ? dest : (uint8_t *) &entry->Age, write ? (uint8_t *) &entry->Age : src, write, &entryOffset,
sizeof(entry->Age)); // INT8U
copyListMember(write ? dest : (uint8_t *) &entry->Allocated, write ? (uint8_t *) &entry->Allocated : src, write,
&entryOffset, sizeof(entry->Allocated)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->LinkEstablished, write ? (uint8_t *) &entry->LinkEstablished : src,
write, &entryOffset, sizeof(entry->LinkEstablished)); // BOOLEAN
break;
}
case 0x003B: // SecurityPolicy
{
entryLength = 3;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _SecurityPolicy
_SecurityPolicy * entry = reinterpret_cast<_SecurityPolicy *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *) &entry->RotationTime, write ? (uint8_t *) &entry->RotationTime : src, write,
&entryOffset, sizeof(entry->RotationTime)); // INT16U
copyListMember(write ? dest : (uint8_t *) &entry->Flags, write ? (uint8_t *) &entry->Flags : src, write, &entryOffset,
sizeof(entry->Flags)); // INT8U
break;
}
case 0x003D: // OperationalDatasetComponents
{
entryLength = 12;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
// Struct _OperationalDatasetComponents
_OperationalDatasetComponents * entry = reinterpret_cast<_OperationalDatasetComponents *>(write ? src : dest);
copyListMember(write ? dest : (uint8_t *) &entry->ActiveTimestampPresent,
write ? (uint8_t *) &entry->ActiveTimestampPresent : src, write, &entryOffset,
sizeof(entry->ActiveTimestampPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->PendingTimestampPresent,
write ? (uint8_t *) &entry->PendingTimestampPresent : src, write, &entryOffset,
sizeof(entry->PendingTimestampPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->MasterKeyPresent, write ? (uint8_t *) &entry->MasterKeyPresent : src,
write, &entryOffset, sizeof(entry->MasterKeyPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->NetworkNamePresent,
write ? (uint8_t *) &entry->NetworkNamePresent : src, write, &entryOffset,
sizeof(entry->NetworkNamePresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->ExtendedPanIdPresent,
write ? (uint8_t *) &entry->ExtendedPanIdPresent : src, write, &entryOffset,
sizeof(entry->ExtendedPanIdPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->MeshLocalPrefixPresent,
write ? (uint8_t *) &entry->MeshLocalPrefixPresent : src, write, &entryOffset,
sizeof(entry->MeshLocalPrefixPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->DelayPresent, write ? (uint8_t *) &entry->DelayPresent : src, write,
&entryOffset, sizeof(entry->DelayPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->PanIdPresent, write ? (uint8_t *) &entry->PanIdPresent : src, write,
&entryOffset, sizeof(entry->PanIdPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->ChannelPresent, write ? (uint8_t *) &entry->ChannelPresent : src,
write, &entryOffset, sizeof(entry->ChannelPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->PskcPresent, write ? (uint8_t *) &entry->PskcPresent : src, write,
&entryOffset, sizeof(entry->PskcPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->SecurityPolicyPresent,
write ? (uint8_t *) &entry->SecurityPolicyPresent : src, write, &entryOffset,
sizeof(entry->SecurityPolicyPresent)); // BOOLEAN
copyListMember(write ? dest : (uint8_t *) &entry->ChannelMaskPresent,
write ? (uint8_t *) &entry->ChannelMaskPresent : src, write, &entryOffset,
sizeof(entry->ChannelMaskPresent)); // BOOLEAN
break;
}
case 0x003E: // ActiveNetworkFaultsList
{
entryLength = 1;
if (((index - 1) * entryLength) > (am->size - entryLength))
{
ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index);
return 0;
}
entryOffset = static_cast<uint16_t>(entryOffset + ((index - 1) * entryLength));
copyListMember(dest, src, write, &entryOffset, entryLength); // NetworkFault
break;
}
}
break;
}
}

return entryLength;
Expand Down Expand Up @@ -191,6 +346,31 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut
break;
}
break;
case 0x0035: // Thread Network Diagnostics Cluster
switch (attributeId)
{
case 0x0007: // NeighborTableList
// Struct _NeighborTable
entryLength = 31;
break;
case 0x0008: // RouteTableList
// Struct _RouteTable
entryLength = 18;
break;
case 0x003B: // SecurityPolicy
// Struct _SecurityPolicy
entryLength = 3;
break;
case 0x003D: // OperationalDatasetComponents
// Struct _OperationalDatasetComponents
entryLength = 12;
break;
case 0x003E: // ActiveNetworkFaultsList
// uint8_t
entryLength = 1;
break;
}
break;
}

uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId)
case ZCL_TEMP_MEASUREMENT_CLUSTER_ID:
emberAfTemperatureMeasurementClusterInitCallback(endpoint);
break;
case ZCL_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_ID:
emberAfThreadNetworkDiagnosticsClusterInitCallback(endpoint);
break;
case ZCL_WIFI_NETWORK_DIAGNOSTICS_CLUSTER_ID:
emberAfWiFiNetworkDiagnosticsClusterInitCallback(endpoint);
break;
Expand Down Expand Up @@ -102,6 +105,11 @@ void __attribute__((weak)) emberAfTemperatureMeasurementClusterInitCallback(Endp
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfThreadNetworkDiagnosticsClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
(void) endpoint;
}
void __attribute__((weak)) emberAfWiFiNetworkDiagnosticsClusterInitCallback(EndpointId endpoint)
{
// To prevent warning
Expand Down
79 changes: 79 additions & 0 deletions examples/temperature-measurement-app/esp32/main/gen/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ void emberAfSoftwareDiagnosticsClusterInitCallback(chip::EndpointId endpoint);
*/
void emberAfTemperatureMeasurementClusterInitCallback(chip::EndpointId endpoint);

/** @brief Thread Network Diagnostics Cluster Init
*
* Cluster Init
*
* @param endpoint Endpoint that is being initialized
*/
void emberAfThreadNetworkDiagnosticsClusterInitCallback(chip::EndpointId endpoint);

/** @brief WiFi Network Diagnostics Cluster Init
*
* Cluster Init
Expand Down Expand Up @@ -680,6 +688,77 @@ EmberAfStatus emberAfTemperatureMeasurementClusterServerPreAttributeChangedCallb
*/
void emberAfTemperatureMeasurementClusterServerTickCallback(chip::EndpointId endpoint);

//
// Thread Network Diagnostics Cluster server
//

/** @brief Thread Network Diagnostics Cluster Server Init
*
* Server Init
*
* @param endpoint Endpoint that is being initialized
*/
void emberAfThreadNetworkDiagnosticsClusterServerInitCallback(chip::EndpointId endpoint);

/** @brief Thread Network Diagnostics Cluster Server Attribute Changed
*
* Server Attribute Changed
*
* @param endpoint Endpoint that is being initialized
* @param attributeId Attribute that changed
*/
void emberAfThreadNetworkDiagnosticsClusterServerAttributeChangedCallback(chip::EndpointId endpoint, chip::AttributeId attributeId);

/** @brief Thread Network Diagnostics Cluster Server Manufacturer Specific Attribute Changed
*
* Server Manufacturer Specific Attribute Changed
*
* @param endpoint Endpoint that is being initialized
* @param attributeId Attribute that changed
* @param manufacturerCode Manufacturer Code of the attribute that changed
*/
void emberAfThreadNetworkDiagnosticsClusterServerManufacturerSpecificAttributeChangedCallback(chip::EndpointId endpoint,
chip::AttributeId attributeId,
uint16_t manufacturerCode);

/** @brief Thread Network Diagnostics Cluster Server Message Sent
*
* Server Message Sent
*
* @param type The type of message sent
* @param destination The destination to which the message was sent
* @param apsFrame The APS frame for the message
* @param msgLen The length of the message
* @param message The message that was sent
* @param status The status of the sent message
*/
void emberAfThreadNetworkDiagnosticsClusterServerMessageSentCallback(const chip::MessageSendDestination & destination,
EmberApsFrame * apsFrame, uint16_t msgLen, uint8_t * message,
EmberStatus status);

/** @brief Thread Network Diagnostics Cluster Server Pre Attribute Changed
*
* server Pre Attribute Changed
*
* @param endpoint Endpoint that is being initialized
* @param attributeId Attribute to be changed
* @param attributeType Attribute type
* @param size Attribute size
* @param value Attribute value
*/
EmberAfStatus emberAfThreadNetworkDiagnosticsClusterServerPreAttributeChangedCallback(chip::EndpointId endpoint,
chip::AttributeId attributeId,
EmberAfAttributeType attributeType,
uint16_t size, uint8_t * value);

/** @brief Thread Network Diagnostics Cluster Server Tick
*
* server Tick
*
* @param endpoint Endpoint that is being served
*/
void emberAfThreadNetworkDiagnosticsClusterServerTickCallback(chip::EndpointId endpoint);

//
// WiFi Network Diagnostics Cluster server
//
Expand Down
Loading

0 comments on commit 5cb5206

Please sign in to comment.