Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of mbed-os-example-mbed5-blinky by
baidu_iot_ota_manager.h
00001 /** 00002 * File: baidu_iot_ota_manager.h 00003 * Auth: Duan Lian(duanlian01@baidu.com) 00004 * Date: 2016.12.21 00005 * Desc: The OTA Manager 00006 */ 00007 #pragma once 00008 #include "rtos.h" 00009 #include "shared_buffer.h" 00010 #include "baidu_iot_ota_reporter.h" 00011 //#include "baidu_iot_ota_package_scanner.h" //k64f 00012 #ifdef TARGET_UNO_91H 00013 #include "package_scanner.h" //rda 00014 #endif 00015 #define OPTIONAL_UPDATE 0 00016 #define MANDATED_UPDATE 1 00017 00018 00019 struct OTAServerUpdateCommand 00020 { 00021 char transaction[65]; 00022 char version[16]; 00023 char old_version[16]; 00024 char url[129]; 00025 char signature[129]; 00026 unsigned int size; 00027 }; 00028 00029 class OTAManager 00030 { 00031 public: 00032 static OTAManager* instance(); 00033 ~OTAManager(); 00034 int checkUpdates(const char *command = 0); 00035 int syncPackageInfo(); 00036 00037 int getOSInfo(os_info_t& info); 00038 private: 00039 enum {SHARED_BUFFER_SIZE = 2048}; 00040 SharedBuffer m_SharedBuffer; 00041 static OTAManager _manager; 00042 bool m_bIdle; 00043 char *m_pUpdateCommand; 00044 OTAReporter *m_pReporter; 00045 rtos::Thread *m_pThread; 00046 rtos::Thread *m_pRestart_thread; 00047 rtos::Mutex m_Lock; 00048 rtos::Semaphore *m_pInstallComplete; 00049 #ifdef TARGET_UNO_91H 00050 PackageScanner m_Scanner; 00051 #endif 00052 00053 OTAManager(); 00054 //check if updates are available and perform downloading 00055 void run_downloader(); 00056 int contact_ota_server(); 00057 int parse_update_command(const char* str_command, OTAServerUpdateCommand &command); 00058 //decrypt package and write data to storage 00059 void run_installer(); 00060 int applyUpdates(const OTAServerUpdateCommand& command); 00061 static int data_available(unsigned char* data, unsigned int len, void* ctx); 00062 static void ota_resart(); 00063 };
Generated on Tue Jul 12 2022 16:28:52 by
1.7.2
