@@ -326,6 +326,10 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
326326 success &= waitResponse (5000L ) == 1 ;
327327 if (!success) { return false ; }
328328
329+ // NOTE: It just works much better if we wait a little bit before asking to
330+ // write the certificate
331+ delay (100 );
332+
329333 // Write File to the Flash Buffer Allocated by CFSINIT
330334 // AT+CFSWFILE=<index>,<file name>,<mode>,<file size>,<input time>
331335 // <index> 3: "/customer/" (always use customer for certificates)
@@ -340,13 +344,21 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
340344 // <len_filename> Integer type. Maximum length of parameter <file name>.
341345 sendAT (GF (" +CFSWFILE=3,\" " ), certificateName, GF (" \" ,0," ), len,
342346 GF (" ,10000" ));
343- success &= waitResponse (5000L , GF (" DOWNLOAD" )) == 1 ;
347+ // The module sends back a 'DOWNLOAD' prompt - sometimes preceded by an 'OK'
348+ // NOTE: If we don't get the "DOWNLOAD" response or somehow miss hearing it,
349+ // we don't write the file. If we don't write something within 10 seconds
350+ // (the <input time>), the terminal will timeout and send back an 'OK' at
351+ // the 10s mark.
352+ success &= waitResponse (10500L , GF (" DOWNLOAD" ), GFP (GSM_OK),
353+ GFP (GSM_ERROR)) == 1 ;
344354
345355 if (success) {
346356 stream.write (cert, len);
347357 stream.flush ();
358+ success &= waitResponse (5000L ) == 1 ;
359+ } else {
360+ DBG (GF (" ### Failed to get download prompt!" ));
348361 }
349- success &= waitResponse (15000L ) == 1 ;
350362
351363 // Verify the size of the uploaded file
352364 // AT+CFSGFIS=<index>,<filename>
@@ -359,6 +371,7 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
359371 streamSkipUntil (' \n ' );
360372 success &= len_confirmed == len;
361373 }
374+ success &= waitResponse (5000L ) == 1 ;
362375
363376 // Release AT relates to file system functions.
364377 // NOTE: We need to do this even if we didn't successfully write the file
@@ -949,11 +962,11 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
949962 const char * pskTableName = thisClient->pskTableName ;
950963
951964 DBG (" ### SSL context index:" , sslCtxIndex);
952- DBG (" SSL auth mode:" , (int )sslAuthMode);
953- DBG (" CA cert name:" , CAcertName);
954- DBG (" Client cert name:" , clientCertName);
955- DBG (" Client key name:" , clientKeyName);
956- DBG (" PSK table name:" , pskTableName);
965+ DBG (" ### SSL auth mode:" , (int )sslAuthMode);
966+ DBG (" ### CA cert name:" , CAcertName);
967+ DBG (" ### Client cert name:" , clientCertName);
968+ DBG (" ### Client key name:" , clientKeyName);
969+ DBG (" ### PSK table name:" , pskTableName);
957970
958971 // NOTE: We cannot link the SSL context or set the certificates until
959972 // AFTER setting the connection id (ie, AT+CACID=mux)
@@ -967,8 +980,8 @@ class TinyGsmSim7080 : public TinyGsmSim70xx<TinyGsmSim7080>,
967980 }
968981 }
969982
970- DBG (" host:" , host);
971- DBG (" port:" , port);
983+ DBG (" ### host:" , host);
984+ DBG (" ### port:" , port);
972985
973986 // actually open the connection
974987 // AT+CAOPEN=<cid>,<pdp_index>,<conn_type>,<server>,<port>[,<recv_mode>]
0 commit comments