20
20
#include < app/AttributeAccessInterfaceRegistry.h>
21
21
#include < app/InteractionModelEngine.h>
22
22
#include < app/reporting/reporting.h>
23
- #include < app/util/config.h>
24
- #include < lib/core/Global.h>
25
23
#include < lib/support/CodeUtils.h>
26
24
27
25
#include < algorithm>
@@ -55,18 +53,11 @@ bool IsValidWpaPersonalCredential(ByteSpan credential)
55
53
return false ;
56
54
}
57
55
58
- Global<WiFiNetworkManagementServer> gWiFiNetworkManagementServerInstance ;
59
-
60
56
} // namespace
61
57
62
- WiFiNetworkManagementServer & WiFiNetworkManagementServer::Instance ()
63
- {
64
- return gWiFiNetworkManagementServerInstance .get ();
65
- }
66
-
67
- WiFiNetworkManagementServer::WiFiNetworkManagementServer () :
68
- AttributeAccessInterface (NullOptional, WiFiNetworkManagement::Id),
69
- CommandHandlerInterface (NullOptional, WiFiNetworkManagement::Id)
58
+ WiFiNetworkManagementServer::WiFiNetworkManagementServer (EndpointId endpoint) :
59
+ AttributeAccessInterface (MakeOptional(endpoint), WiFiNetworkManagement::Id),
60
+ CommandHandlerInterface (MakeOptional(endpoint), WiFiNetworkManagement::Id)
70
61
{}
71
62
72
63
WiFiNetworkManagementServer::~WiFiNetworkManagementServer ()
@@ -75,12 +66,8 @@ WiFiNetworkManagementServer::~WiFiNetworkManagementServer()
75
66
InteractionModelEngine::GetInstance ()->UnregisterCommandHandler (this );
76
67
}
77
68
78
- CHIP_ERROR WiFiNetworkManagementServer::Init (EndpointId endpoint )
69
+ CHIP_ERROR WiFiNetworkManagementServer::Init ()
79
70
{
80
- VerifyOrReturnError (endpoint != kInvalidEndpointId , CHIP_ERROR_INVALID_ARGUMENT);
81
- VerifyOrReturnError (mEndpointId == kInvalidEndpointId , CHIP_ERROR_INCORRECT_STATE);
82
-
83
- mEndpointId = endpoint;
84
71
VerifyOrReturnError (registerAttributeAccessOverride (this ), CHIP_ERROR_INTERNAL);
85
72
ReturnErrorOnFailure (InteractionModelEngine::GetInstance ()->RegisterCommandHandler (this ));
86
73
return CHIP_NO_ERROR;
@@ -92,7 +79,7 @@ CHIP_ERROR WiFiNetworkManagementServer::ClearNetworkCredentials()
92
79
93
80
mSsidLen = 0 ;
94
81
mPassphrase .SetLength (0 );
95
- MatterReportingAttributeChangeCallback (mEndpointId , WiFiNetworkManagement::Id, Ssid::Id);
82
+ MatterReportingAttributeChangeCallback (GetEndpointId () , WiFiNetworkManagement::Id, Ssid::Id);
96
83
return CHIP_NO_ERROR;
97
84
}
98
85
@@ -114,7 +101,7 @@ CHIP_ERROR WiFiNetworkManagementServer::SetNetworkCredentials(ByteSpan ssid, Byt
114
101
// Note: The spec currently defines no way to signal a passphrase change
115
102
if (ssidChanged)
116
103
{
117
- MatterReportingAttributeChangeCallback (mEndpointId , WiFiNetworkManagement::Id, Ssid::Id);
104
+ MatterReportingAttributeChangeCallback (GetEndpointId () , WiFiNetworkManagement::Id, Ssid::Id);
118
105
}
119
106
return CHIP_NO_ERROR;
120
107
}
@@ -160,17 +147,4 @@ void WiFiNetworkManagementServer::HandleNetworkPassphraseRequest(HandlerContext
160
147
} // namespace app
161
148
} // namespace chip
162
149
163
- #if defined(MATTER_DM_WIFI_NETWORK_MANAGEMENT_CLUSTER_SERVER_ENDPOINT_COUNT) && \
164
- MATTER_DM_WIFI_NETWORK_MANAGEMENT_CLUSTER_SERVER_ENDPOINT_COUNT > 1
165
- #error Only a single Wi-Fi Network Management Cluster instance is supported.
166
- #endif
167
-
168
150
void MatterWiFiNetworkManagementPluginServerInitCallback () {}
169
-
170
- void emberAfWiFiNetworkManagementClusterServerInitCallback (EndpointId endpoint)
171
- {
172
- // We could delay constructing the instance until this point; however it's not
173
- // clear if this is inconvenient in terms of forcing the application to initialize
174
- // the network credentials later than it otherwise would.
175
- LogErrorOnFailure (chip::app::Clusters::WiFiNetworkManagementServer::Instance ().Init (endpoint));
176
- }
0 commit comments