@@ -84,10 +84,10 @@ const int NCP_FW_UUFWINSTALL_COMPLETE = 128;
8484 * };
8585 */
8686const SaraNcpFwUpdateConfig SARA_NCP_FW_UPDATE_CONFIG[] = {
87- // { sizeof(SaraNcpFwUpdateConfig), 3140001, 103140001 , "SARA-R510S-01B-00-ES-0314A0001_SARA-R510S-01B-00-XX-0314ENG0099A0001.upd", "09c1a98d03c761bcbea50355f9b2a50f" },
88- // { sizeof(SaraNcpFwUpdateConfig), 103140001, 3140001 , "SARA-R510S-01B-00-XX-0314ENG0099A0001_SARA-R510S-01B-00-ES-0314A0001.upd", "136caf2883457093c9e41fda3c6a44e3" },
89- // { sizeof(SaraNcpFwUpdateConfig), 2060001, 99010001 , "SARA-R510S-00B-01_FW02.06_A00.01_IP_SARA-R510S-00B-01_FW99.01_A00.01.upd", "ccfdc48c0a45198d6e168b30d0740959" },
90- // { sizeof(SaraNcpFwUpdateConfig), 99010001, 2060001 , "SARA-R510S-00B-01_FW99.01_A00.01_SARA-R510S-00B-01_FW02.06_A00.01_IP.upd", "5fd6c0d3d731c097605895b86f28c2cf" },
87+ // { sizeof(SaraNcpFwUpdateConfig), 31400010, 31400011 , "SARA-R510S-01B-00-ES-0314A0001_SARA-R510S-01B-00-XX-0314ENG0099A0001.upd", "09c1a98d03c761bcbea50355f9b2a50f" },
88+ // { sizeof(SaraNcpFwUpdateConfig), 31400011, 31400010 , "SARA-R510S-01B-00-XX-0314ENG0099A0001_SARA-R510S-01B-00-ES-0314A0001.upd", "136caf2883457093c9e41fda3c6a44e3" },
89+ // { sizeof(SaraNcpFwUpdateConfig), 20600010, 990100010 , "SARA-R510S-00B-01_FW02.06_A00.01_IP_SARA-R510S-00B-01_FW99.01_A00.01.upd", "ccfdc48c0a45198d6e168b30d0740959" },
90+ // { sizeof(SaraNcpFwUpdateConfig), 990100010, 20600010 , "SARA-R510S-00B-01_FW99.01_A00.01_SARA-R510S-00B-01_FW02.06_A00.01_IP.upd", "5fd6c0d3d731c097605895b86f28c2cf" },
9191};
9292const size_t SARA_NCP_FW_UPDATE_CONFIG_SIZE = sizeof (SARA_NCP_FW_UPDATE_CONFIG) / sizeof (SARA_NCP_FW_UPDATE_CONFIG[0 ]);
9393
@@ -460,17 +460,18 @@ int SaraNcpFwUpdate::process() {
460460 NCPFW_LOG (INFO, " Disconnecting Cellular..." );
461461 // network_disconnect() doesn't wait for final OK response from CFUN=0
462462 // wait for DETACH: +CGEV: ME PDN DEACT 1
463- // FIXME: Note that this uses internals of the NCP client/parser and that a new cellular_hal API
464- // should be added for this functionality later, as in all the other places we are using
465- // cellular_commandas opposed to directly calling into ncp client/parser.
466- // FIXME
467- #ifndef UNIT_TEST
468- auto mgr = cellularNetworkManager ();
469- auto client = mgr->ncpClient ();
470- auto parser = client->atParser ();
471- const NcpClientLock lock (client);
472- parser->addUrcHandler (" +CGEV" , cgevCallback, this );
473- #endif // UNIT_TEST
463+ cellular_add_urc_handler (" +CGEV" , [](const char * data, void * context) -> int {
464+ const auto self = (SaraNcpFwUpdate*)context;
465+ int profile;
466+
467+ int r = ::sscanf (data, " +CGEV: ME PDN DEACT %d" , &profile);
468+ // do not CHECK_TRUE as we intend to ignore +CGEV: ME DETACH
469+ if (r >= 1 ) {
470+ self->cgevDeactProfile_ = profile;
471+ }
472+
473+ return SYSTEM_ERROR_NONE;
474+ }, this );
474475 cgevDeactProfile_ = 0 ;
475476 startTimer_ = millis ();
476477 network_disconnect (0 , NETWORK_DISCONNECT_REASON_USER, 0 );
@@ -537,17 +538,25 @@ int SaraNcpFwUpdate::process() {
537538 }
538539 }
539540
540- // FIXME: Note that this uses internals of the NCP client/parser and that a new cellular_hal API
541- // should be added for this functionality later, as in all the other places we are using
542- // cellular_commandas opposed to directly calling into ncp client/parser.
543- // FIXME
544- #ifndef UNIT_TEST
545- auto mgr = cellularNetworkManager ();
546- auto client = mgr->ncpClient ();
547- auto parser = client->atParser ();
548- const NcpClientLock lock (client);
549- parser->addUrcHandler (" +UUHTTPCR" , httpRespCallback, this );
550- #endif // UNIT_TEST
541+ cellular_add_urc_handler (" +UUHTTPCR" , [](const char * data, void * context) -> int {
542+ const auto self = (SaraNcpFwUpdate*)context;
543+ int a, b, c;
544+ char s[40 ];
545+
546+ int r = ::sscanf (data, " +UUHTTPCR: %*d,%d,%d,%d,\" %32s\" " , &a, &b, &c, s);
547+ CHECK_TRUE (r >= 3 , SYSTEM_ERROR_AT_RESPONSE_UNEXPECTED);
548+
549+ self->httpsResp_ .valid = false ; // make following lines atomic
550+ self->httpsResp_ .command = a;
551+ self->httpsResp_ .result = b;
552+ self->httpsResp_ .status_code = c;
553+ if (r > 3 ) {
554+ memcpy (self->httpsResp_ .md5_sum , &s, sizeof (s));
555+ }
556+ self->httpsResp_ .valid = true ;
557+
558+ return SYSTEM_ERROR_NONE;
559+ }, this );
551560
552561 NCPFW_LOG (INFO, " Starting download..." );
553562#if SARA_NCP_FW_UPDATE_ENABLE_DOWNLOAD
@@ -575,6 +584,8 @@ int SaraNcpFwUpdate::process() {
575584 }
576585 }
577586 }
587+
588+ cellular_remove_urc_handler (" +UUHTTPCR" );
578589#else // SARA_NCP_FW_UPDATE_ENABLE_DOWNLOAD
579590 // DEBUG
580591 modemFirmwareDownloadComplete = true ;
@@ -606,6 +617,7 @@ int SaraNcpFwUpdate::process() {
606617 {
607618 if (cgevDeactProfile_ == NCP_FW_UBLOX_DEFAULT_CID) { // Default CID detached
608619 NCPFW_LOG (INFO, " Disconnected Cellular." );
620+ cellular_remove_urc_handler (" +CGEV" );
609621 saraNcpFwUpdateState_ = FW_UPDATE_STATE_INSTALL_STARTING;
610622 cooldown (1000 ); // allow other disconnect URCs to pass
611623 }
0 commit comments