@@ -140,34 +140,31 @@ void MPDevice::setupMessageProtocol()
140
140
141
141
void MPDevice::sendInitMessages ()
142
142
{
143
- statusTimer->start (500 );
144
- QTimer::singleShot (100 , [this ]() {
145
- if (isBLE ())
143
+ statusTimer->start (STATUS_STARTING_DELAY);
144
+ addTimerJob (INIT_STARTING_DELAY);
145
+ if (isBLE ())
146
+ {
147
+ /* *
148
+ * Reset Flip Bit is written directly to device
149
+ * so TimerJob has no effect, hence sending
150
+ * it with a lower timeout.
151
+ */
152
+ QTimer::singleShot (INIT_STARTING_DELAY/2 , [this ]()
146
153
{
147
154
if (AppDaemon::isDebugDev ())
148
155
qDebug () << " Resetting flip bit for BLE" ;
149
-
150
156
bleImpl->sendResetFlipBit ();
151
- if (bleImpl->isAfterAuxFlash ())
152
- {
153
- qDebug () << " Fixing communication with device after Aux Flash" ;
154
- writeCancelRequest ();
155
- }
156
- bleImpl->getPlatInfo ();
157
- }
157
+ });
158
158
159
- exitMemMgmtMode (false );
160
- // TODO Remove when GET_MOOLTIPASS_PARM implemented for BLE
161
- /* *
162
- * Temporary solution until GET_MOOLTIPASS_PARM
163
- * is not implemented for the ble device we do not
164
- * get if BLE is detected.
165
- */
166
- if (isBLE ())
159
+ if (bleImpl->isAfterAuxFlash ())
167
160
{
168
- flashMbSizeChanged (0 );
161
+ qDebug () << " Fixing communication with device after Aux Flash" ;
162
+ writeCancelRequest ();
169
163
}
170
- });
164
+ bleImpl->getPlatInfo ();
165
+ }
166
+
167
+ exitMemMgmtMode (false );
171
168
}
172
169
173
170
void MPDevice::sendData (MPCmd::Command c, const QByteArray &data, quint32 timeout, MPCommandCb cb, bool checkReturn)
@@ -500,6 +497,14 @@ void MPDevice::runAndDequeueJobs()
500
497
currentJobs->start ();
501
498
}
502
499
500
+ void MPDevice::addTimerJob (int msec)
501
+ {
502
+ auto *waitingJob = new AsyncJobs (QString (" Waiting job" ), this );
503
+ waitingJob->append (new TimerJob{msec});
504
+ jobsQueue.enqueue (waitingJob);
505
+ runAndDequeueJobs ();
506
+ }
507
+
503
508
void MPDevice::updateFilesCache ()
504
509
{
505
510
getStoredFiles ([this ](bool success, QList<QVariantMap> files)
0 commit comments