#ifndef _EKEN_UPRAGDE_H_
#define _EKEN_UPRAGDE_H_
#include "iobuffer.h"

typedef enum{
  		READY=1,
		READY_FAIL = 2,
		UPGRADING = 3,//for progress
		DOWNLOAD_OK = 4,
		DOWNLOAD_FAIL = 5,
		CRC_FAIL = 11,
		INSTALL_ING= 12,
		INSTALL_OK= 13,
		INSTALL_FAIL= 14,
		UPGRADE_KERNEL = 16,
		UPGRADE_ALL = 18,
		BATTERY_LOW = 19,
		MCU_FAIL = 20,
}UPGRADE_STATUS;

typedef void (*onDownloadImageProgress)(UPGRADE_STATUS status, int progress);


//How to use:
// 1 ./build.sh 3
// 2 generate the OTA package in V831\source\workspace\suniv\beetles\mkimage\DBV7PRO_MAIN_WIFI_001.ota
// 3 upload the ota to http server
// 4 eken_test OTA http://mysafelock.com/test/DBV7PRO_MAIN_WIFI_001.ota

//create task to download OTA package from http url
//1 after verify, upgrade 831 through aw_upgrade API aw_upgrade_slice
//  after upgrade, aw_upgrade_end switch the BOOTA/BOOTB partition
//2 store the 7682 image in new 1MB USER partition in source/projects/defconfig/eken/aw_eken/sys_partition.fex
//  after verify, notify MT7682 to upgrade(bl_sota_write_update_info) and reboot
//3 after 7682 and 831 reboot, the first handshake packet should notify 831 to upgrade 7682
//4 831 send 7682 image through SDIO interface in upgradeMT7682
void createUpgradeTask(char *otaURL, onDownloadImageProgress listener);

// send MT7682 image through SDIO interface
int upgradeMT7682(void);

int isUpgrading(void);

iobuffer* getOTAIOBuffer();
int startOTAFromIOBuffer(onDownloadImageProgress listener);

#endif