22
22
* Implements all the callbacks to the application from the CHIP Stack
23
23
*
24
24
**/
25
+
25
26
#include " DeviceCallbacks.h"
26
27
27
- #include " CHIPDeviceManager.h"
28
+ #include < common/CHIPDeviceManager.h>
29
+
28
30
#include < app-common/zap-generated/attribute-id.h>
29
31
#include < app-common/zap-generated/cluster-id.h>
30
32
#include < app/CommandHandler.h>
@@ -49,75 +51,8 @@ using namespace ::chip::Logging;
49
51
uint32_t identifyTimerCount;
50
52
constexpr uint32_t kIdentifyTimerDelayMS = 250 ;
51
53
52
- void DeviceCallbacks::DeviceEventCallback (const ChipDeviceEvent * event, intptr_t arg)
53
- {
54
- ChipLogProgress (Zcl, " DeviceEventCallback, event->Type:%d \r\n " , event->Type );
55
- switch (event->Type )
56
- {
57
- case DeviceEventType::kInternetConnectivityChange :
58
- OnInternetConnectivityChange (event);
59
- break ;
60
-
61
- // case DeviceEventType::kSessionEstablished:
62
- // OnSessionEstablished(event);
63
- // break;
64
- case DeviceEventType::kInterfaceIpAddressChanged :
65
- ChipLogProgress (Zcl, " IP(%s) changed event" ,
66
- (event->InterfaceIpAddressChanged .Type == InterfaceIpChangeType::kIpV4_Assigned ) ? " IPv4" : " IPv6" );
67
- if ((event->InterfaceIpAddressChanged .Type == InterfaceIpChangeType::kIpV4_Assigned ) ||
68
- (event->InterfaceIpAddressChanged .Type == InterfaceIpChangeType::kIpV6_Assigned ))
69
- {
70
- // MDNS server restart on any ip assignment: if link local ipv6 is configured, that
71
- // will not trigger a 'internet connectivity change' as there is no internet
72
- // connectivity. MDNS still wants to refresh its listening interfaces to include the
73
- // newly selected address.
74
- chip::app::DnssdServer::Instance ().StartServer ();
75
- }
76
- break ;
77
- case DeviceEventType::kCHIPoBLEConnectionEstablished :
78
- ChipLogProgress (Zcl, " CHIPoBLE connection established" );
79
- break ;
80
- case DeviceEventType::kCHIPoBLEConnectionClosed :
81
- ChipLogProgress (Zcl, " CHIPoBLE disconnected" );
82
- break ;
83
- case DeviceEventType::kCommissioningComplete :
84
- ChipLogProgress (Zcl, " Commissioning complete" );
85
- break ;
86
- }
87
- }
88
-
89
- void DeviceCallbacks::OnInternetConnectivityChange (const ChipDeviceEvent * event)
90
- {
91
- if (event->InternetConnectivityChange .IPv4 == kConnectivity_Established )
92
- {
93
- ChipLogProgress (Zcl, " Server ready at:%d" , CHIP_PORT);
94
- // chip::app::DnssdServer::Instance().StartServer();
95
- }
96
- else if (event->InternetConnectivityChange .IPv4 == kConnectivity_Lost )
97
- {
98
- ChipLogProgress (Zcl, " Lost IPv4 connectivity..." );
99
- }
100
- if (event->InternetConnectivityChange .IPv6 == kConnectivity_Established )
101
- {
102
- ChipLogProgress (Zcl, " IPv6 Server ready..." );
103
- chip::app::DnssdServer::Instance ().StartServer ();
104
- }
105
- else if (event->InternetConnectivityChange .IPv6 == kConnectivity_Lost )
106
- {
107
- ChipLogProgress (Zcl, " Lost IPv6 connectivity..." );
108
- }
109
- }
110
-
111
- void DeviceCallbacks::OnSessionEstablished (const ChipDeviceEvent * event)
112
- {
113
- if (event->SessionEstablished .IsCommissioner )
114
- {
115
- ChipLogProgress (Zcl, " Commissioner detected!" );
116
- }
117
- }
118
-
119
- void DeviceCallbacks::PostAttributeChangeCallback (EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
120
- uint8_t type, uint16_t size, uint8_t * value)
54
+ void AppDeviceCallbacks::PostAttributeChangeCallback (EndpointId endpointId, ClusterId clusterId, AttributeId attributeId,
55
+ uint8_t type, uint16_t size, uint8_t * value)
121
56
{
122
57
switch (clusterId)
123
58
{
@@ -135,7 +70,7 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster
135
70
}
136
71
}
137
72
138
- void DeviceCallbacks ::OnOnOffPostAttributeChangeCallback (EndpointId endpointId, AttributeId attributeId, uint8_t * value)
73
+ void AppDeviceCallbacks ::OnOnOffPostAttributeChangeCallback (EndpointId endpointId, AttributeId attributeId, uint8_t * value)
139
74
{
140
75
VerifyOrExit (attributeId == ZCL_ON_OFF_ATTRIBUTE_ID,
141
76
ChipLogError (DeviceLayer, TAG, " Unhandled Attribute ID: '0x%04x" , attributeId));
@@ -161,7 +96,7 @@ void IdentifyTimerHandler(Layer * systemLayer, void * appState)
161
96
}
162
97
}
163
98
164
- void DeviceCallbacks ::OnIdentifyPostAttributeChangeCallback (EndpointId endpointId, AttributeId attributeId, uint8_t * value)
99
+ void AppDeviceCallbacks ::OnIdentifyPostAttributeChangeCallback (EndpointId endpointId, AttributeId attributeId, uint8_t * value)
165
100
{
166
101
VerifyOrExit (attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID,
167
102
ChipLogError (DeviceLayer, " [%s] Unhandled Attribute ID: '0x%04x" , TAG, attributeId));
@@ -178,9 +113,3 @@ void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback(EndpointId endpointI
178
113
exit :
179
114
return ;
180
115
}
181
-
182
- bool emberAfBasicClusterMfgSpecificPingCallback (chip::app::CommandHandler * commandObj)
183
- {
184
- emberAfSendDefaultResponse (emberAfCurrentCommand (), EMBER_ZCL_STATUS_SUCCESS);
185
- return true ;
186
- }
0 commit comments