@@ -115,17 +115,6 @@ static void _ota_callback(void *pcontext, const char *msg, uint32_t msg_len) {
115115 goto End ;
116116 }
117117
118- if (NULL == (h_ota -> ch_fetch = ofc_Init (h_ota -> purl ))) {
119- Log_e ("Initialize fetch module failed" );
120- goto End ;
121- }
122-
123- if (0 != qcloud_ofc_connect (h_ota -> ch_fetch )) {
124- Log_e ("Connect fetch module failed" );
125- h_ota -> state = IOT_OTAS_DISCONNECTED ;
126- goto End ;
127- }
128-
129118 h_ota -> state = IOT_OTAS_FETCHING ;
130119 }
131120
@@ -337,6 +326,38 @@ int IOT_OTA_Destroy(void *handle)
337326 return 0 ;
338327}
339328
329+ /*support continuous transmission of breakpoints*/
330+ int IOT_OTA_StartDownload (void * handle , uint32_t offset , uint32_t size )
331+ {
332+ OTA_Struct_t * h_ota = (OTA_Struct_t * ) handle ;
333+ int Ret ;
334+
335+ h_ota -> size_fetched += offset ;
336+ h_ota -> ch_fetch = ofc_Init (h_ota -> purl , offset , size );
337+ if (NULL == h_ota -> ch_fetch ) {
338+ Log_e ("Initialize fetch module failed" );
339+ return QCLOUD_ERR_FAILURE ;
340+ }
341+
342+ Ret = qcloud_ofc_connect (h_ota -> ch_fetch );
343+ if (QCLOUD_ERR_SUCCESS != Ret ) {
344+ Log_e ("Connect fetch module failed" );
345+ h_ota -> state = IOT_OTAS_DISCONNECTED ;
346+ }
347+
348+ return Ret ;
349+ }
350+
351+ /*support continuous transmission of breakpoints*/
352+ void IOT_OTA_UpdateClientMd5 (void * handle , char * buff , uint32_t size )
353+ {
354+ OTA_Struct_t * h_ota = (OTA_Struct_t * ) handle ;
355+
356+ qcloud_otalib_md5_update (h_ota -> md5 , buff , size );
357+ }
358+
359+
360+
340361int IOT_OTA_ReportVersion (void * handle , const char * version )
341362{
342363#define MSG_INFORM_LEN (128)
@@ -400,12 +421,31 @@ int IOT_OTA_ReportUpgradeBegin(void *handle)
400421
401422int IOT_OTA_ReportUpgradeSuccess (void * handle , const char * version )
402423{
403- return IOT_OTA_ReportUpgradeResult (handle , version , IOT_OTAR_UPGRADE_SUCCESS );
424+ OTA_Struct_t * h_ota = (OTA_Struct_t * ) handle ;
425+ int ret ;
426+
427+ if (NULL == version ){
428+ ret = IOT_OTA_ReportUpgradeResult (handle , h_ota -> version , IOT_OTAR_UPGRADE_SUCCESS );
429+ }else {
430+ ret = IOT_OTA_ReportUpgradeResult (handle , version , IOT_OTAR_UPGRADE_SUCCESS );
431+ }
432+
433+ return ret ;
404434}
405435
436+
406437int IOT_OTA_ReportUpgradeFail (void * handle , const char * version )
407438{
408- return IOT_OTA_ReportUpgradeResult (handle , version , IOT_OTAR_UPGRADE_FAIL );
439+ OTA_Struct_t * h_ota = (OTA_Struct_t * ) handle ;
440+ int ret ;
441+
442+ if (NULL == version ){
443+ ret = IOT_OTA_ReportUpgradeResult (handle , h_ota -> version , IOT_OTAR_UPGRADE_FAIL );
444+ }else {
445+ ret = IOT_OTA_ReportUpgradeResult (handle , version , IOT_OTAR_UPGRADE_FAIL );
446+ }
447+
448+ return ret ;
409449}
410450
411451
0 commit comments