Skip to content

Commit

Permalink
A few more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mwswartwout committed Apr 17, 2024
1 parent 321b7d7 commit fc4a2e5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ void GenericConnectivityManagerImpl_Thread<ImplClass>::UpdateServiceConnectivity

{
ChipDeviceEvent event{ .Type = DeviceEventType::kServiceConnectivityChange,
.ServiceConnectivityChange = {
.Overall = { .Result = event.ServiceConnectivityChange.ViaThread.Result },
.ViaThread = { .Result = (haveServiceConnectivity) ? kConnectivity_Established
: kConnectivity_Lost } } };
CHIP_ERROR status = PlatformMgr().PostEvent(&event);
.ServiceConnectivityChange = { .ViaThread = { .Result = (haveServiceConnectivity)
? kConnectivity_Established
: kConnectivity_Lost } } };
event.ServiceConnectivityChange.Overall.Result = event.ServiceConnectivityChange.ViaThread.Result;
CHIP_ERROR status = PlatformMgr().PostEvent(&event);
if (status != CHIP_NO_ERROR)
{
ChipLogError(DeviceLayer, "Failed to post thread connectivity change: %" CHIP_ERROR_FORMAT, status.Format());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ NetworkCommissioning::otScanResponseIterator<NetworkCommissioning::ThreadScanRes
template <class ImplClass>
void GenericThreadStackManagerImpl_OpenThread<ImplClass>::OnOpenThreadStateChange(uint32_t flags, void * context)
{
ChipDeviceEvent event;
event.Type = DeviceEventType::kThreadStateChange;
event.ThreadStateChange.RoleChanged = (flags & OT_CHANGED_THREAD_ROLE) != 0;
event.ThreadStateChange.AddressChanged = (flags & (OT_CHANGED_IP6_ADDRESS_ADDED | OT_CHANGED_IP6_ADDRESS_REMOVED)) != 0;
event.ThreadStateChange.NetDataChanged = (flags & OT_CHANGED_THREAD_NETDATA) != 0;
event.ThreadStateChange.ChildNodesChanged = (flags & (OT_CHANGED_THREAD_CHILD_ADDED | OT_CHANGED_THREAD_CHILD_REMOVED)) != 0;
event.ThreadStateChange.OpenThread.Flags = flags;
ChipDeviceEvent event
{
.Type = DeviceEventType::kThreadStateChange;
.ThreadStateChange = {
.RoleChanged = (flags & OT_CHANGED_THREAD_ROLE) != 0,
.AddressChanged = (flags & (OT_CHANGED_IP6_ADDRESS_ADDED | OT_CHANGED_IP6_ADDRESS_REMOVED)) != 0,
.NetDataChanged = (flags & OT_CHANGED_THREAD_NETDATA) != 0,
.ChildNodesChanged = (flags & (OT_CHANGED_THREAD_CHILD_ADDED | OT_CHANGED_THREAD_CHILD_REMOVED)) != 0,
.OpenThread = { .Flags = flags }
}
};

CHIP_ERROR status = PlatformMgr().PostEvent(&event);
if (status != CHIP_NO_ERROR)
Expand Down Expand Up @@ -210,11 +214,10 @@ void GenericThreadStackManagerImpl_OpenThread<ImplClass>::_OnPlatformEvent(const
// Avoid sending muliple events if the attachement state didn't change (Child->router or disable->Detached)
if (event->ThreadStateChange.RoleChanged && (isThreadAttached != mIsAttached))
{
ChipDeviceEvent attachEvent;
attachEvent.Clear();
attachEvent.Type = DeviceEventType::kThreadConnectivityChange;
attachEvent.ThreadConnectivityChange.Result = (isThreadAttached) ? kConnectivity_Established : kConnectivity_Lost;
CHIP_ERROR status = PlatformMgr().PostEvent(&attachEvent);
ChipDeviceEvent attachEvent{ .Type = DeviceEventType::kThreadConnectivityChange,
.ThreadConnectivityChange = { .Result = (isThreadAttached) ? kConnectivity_Established
: kConnectivity_Lost } };
CHIP_ERROR status = PlatformMgr().PostEvent(&attachEvent);
if (status == CHIP_NO_ERROR)
{
mIsAttached = isThreadAttached;
Expand Down Expand Up @@ -300,9 +303,8 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadProvis
}

// post an event alerting other subsystems about change in provisioning state
ChipDeviceEvent event;
event.Type = DeviceEventType::kServiceProvisioningChange;
event.ServiceProvisioningChange.IsServiceProvisioned = true;
ChipDeviceEvent event{ .Type = DeviceEventType::kServiceProvisioningChange,
.ServiceProvisioningChange = { .IsServiceProvisioned = true } };
return PlatformMgr().PostEvent(&event);
}

Expand Down

0 comments on commit fc4a2e5

Please sign in to comment.