@@ -45,20 +45,14 @@ void DeRestPluginPrivate::initOtau()
4545{
4646 otauIdleTicks = 0 ;
4747 otauBusyTicks = 0 ;
48- otauNotifyIter = 0 ;
4948 otauIdleTotalCounter = 0 ;
5049 otauUnbindIdleTotalCounter = 0 ;
51- otauNotifyDelay = deCONZ::appArgumentNumeric (" --otau-notify-delay" , OTAU_IDLE_TICKS_NOTIFY);
5250
5351 otauTimer = new QTimer (this );
5452 otauTimer->setSingleShot (false );
5553 connect (otauTimer, SIGNAL (timeout ()),
5654 this , SLOT (otauTimerFired ()));
5755
58- if (otauNotifyDelay > 0 )
59- {
60- otauTimer->start (1000 );
61- }
6256}
6357
6458/* ! Handler for incoming otau packets.
@@ -120,16 +114,14 @@ void DeRestPluginPrivate::otauDataIndication(const deCONZ::ApsDataIndication &in
120114 {
121115 lightNode->setLastRead (READ_SWBUILD_ID, idleTotalCounter);
122116 lightNode->enableRead (READ_SWBUILD_ID);
123- lightNode->setNextReadTime (READ_SWBUILD_ID, queryTime.addSecs (120 ));
117+ lightNode->setNextReadTime (READ_SWBUILD_ID, queryTime.addSecs (160 ));
118+ storeRecoverOnOffBri (lightNode);
124119 }
125120 }
126- else if (( ind.clusterId () == OTAU_CLUSTER_ID) && (( zclFrame.commandId () == OTAU_IMAGE_PAGE_REQUEST_CMD_ID) || (zclFrame. commandId () == OTAU_IMAGE_BLOCK_REQUEST_CMD_ID)) )
121+ else if (ind.clusterId () == OTAU_CLUSTER_ID && zclFrame.commandId () == OTAU_IMAGE_BLOCK_REQUEST_CMD_ID)
127122 {
128123 // remember last activity time
129124 otauIdleTotalCounter = idleTotalCounter;
130-
131- LightNode *lightNode = getLightNodeForAddress (ind.srcAddress (), ind.srcEndpoint ());
132- storeRecoverOnOffBri (lightNode);
133125 }
134126
135127 if (!isOtauActive ())
@@ -155,52 +147,6 @@ void DeRestPluginPrivate::otauDataIndication(const deCONZ::ApsDataIndication &in
155147 }
156148}
157149
158- /* ! Sends otau notifcation (std otau cluster) to \p node.
159- The node will then send a query next image request.
160- */
161- void DeRestPluginPrivate::otauSendStdNotify (LightNode *node)
162- {
163- deCONZ::ApsDataRequest req;
164- deCONZ::ZclFrame zclFrame;
165-
166- req.setProfileId (HA_PROFILE_ID);
167- req.setClusterId (OTAU_CLUSTER_ID);
168- req.setDstAddressMode (deCONZ::ApsExtAddress);
169- req.dstAddress ().setExt (node->address ().ext ());
170- req.setDstEndpoint (node->haEndpoint ().endpoint ());
171- req.setSrcEndpoint (endpoint ());
172- req.setState (deCONZ::FireAndForgetState);
173-
174- zclFrame.setSequenceNumber (zclSeq++);
175- zclFrame.setCommandId (OTAU_IMAGE_NOTIFY_CMD_ID);
176-
177- zclFrame.setFrameControl (deCONZ::ZclFCClusterCommand |
178- deCONZ::ZclFCDirectionServerToClient |
179- deCONZ::ZclFCDisableDefaultResponse);
180-
181- { // payload
182- QDataStream stream (&zclFrame.payload (), QIODevice::WriteOnly);
183- stream.setByteOrder (QDataStream::LittleEndian);
184-
185- uint8_t payloadType = 0x00 ; // query jitter
186- uint8_t queryJitter = 100 ;
187-
188- stream << payloadType;
189- stream << queryJitter;
190- }
191-
192- { // ZCL frame
193- QDataStream stream (&req.asdu (), QIODevice::WriteOnly);
194- stream.setByteOrder (QDataStream::LittleEndian);
195- zclFrame.writeToStream (stream);
196- }
197-
198- if (apsCtrlWrapper.apsdeDataRequest (req) != deCONZ::Success)
199- {
200- DBG_Printf (DBG_INFO, " otau failed to send image notify request\n " );
201- }
202- }
203-
204150/* ! Returns true if otau is busy with uploading data.
205151 */
206152bool DeRestPluginPrivate::isOtauBusy ()
@@ -249,21 +195,11 @@ void DeRestPluginPrivate::otauTimerFired()
249195 return ;
250196 }
251197
252- if (otauNotifyDelay == 0 )
253- {
254- return ;
255- }
256-
257198 if (!isInNetwork ())
258199 {
259200 return ;
260201 }
261202
262- if (nodes.empty ())
263- {
264- return ;
265- }
266-
267203 if (otauIdleTicks < INT_MAX)
268204 {
269205 otauIdleTicks++;
@@ -279,67 +215,5 @@ void DeRestPluginPrivate::otauTimerFired()
279215 }
280216 }
281217
282- if (otauIdleTicks < otauNotifyDelay)
283- {
284- return ;
285- }
286-
287- if (otauNotifyIter >= nodes.size ())
288- {
289- otauNotifyIter = 0 ;
290- }
291-
292- // dont do anything if sensors are triggering group commands
293- if ((idleTotalCounter - sensorIndIdleTotalCounter) < (60 * 10 ))
294- {
295- return ;
296- }
297-
298- LightNode *lightNode = &nodes[otauNotifyIter];
299- otauNotifyIter++;
300-
301- if (!lightNode->isAvailable () &&
302- lightNode->otauClusterId () != OTAU_CLUSTER_ID)
303- {
304- return ;
305- }
306-
307- // filter vendor
308- if (lightNode->manufacturerCode () != VENDOR_DDEL)
309- {
310- return ;
311- }
312-
313- // whitelist active notify to some devices
314- if (lightNode->modelId ().startsWith (" FLS-NB" ))
315- { }
316- else if (lightNode->modelId ().startsWith (" FLS-PP3" ))
317- { }
318- else if (lightNode->modelId ().startsWith (" FLS-A" ))
319- { }
320- else
321- {
322- return ;
323- }
324-
325- QDateTime now = QDateTime::currentDateTime ();
326- NodeValue &val = lightNode->getZclValue (OTAU_CLUSTER_ID, OTAU_SWVERSION_ID);
327-
328- if (val.updateType == NodeValue::UpdateByZclRead)
329- {
330- if (val.timestamp .isValid () && val.timestamp .secsTo (now) < OTAU_NOTIFY_INTERVAL)
331- {
332- return ;
333- }
334-
335- if (val.timestampLastReadRequest .isValid () && val.timestampLastReadRequest .secsTo (now) < OTAU_NOTIFY_INTERVAL)
336- {
337- return ;
338- }
339-
340- val.timestampLastReadRequest = now;
341- }
342-
343- otauSendStdNotify (lightNode);
344218 otauIdleTicks = 0 ;
345219}
0 commit comments