l.yang | 7d7b51c | 2023-08-04 17:02:48 +0800 | [diff] [blame] | 1 | /*******************************************************
|
| 2 | *
|
| 3 | * @brief:
|
| 4 | * @details: add fota upgrade api
|
| 5 | * @author: l.yang
|
| 6 | * @date: 2023.8.3
|
| 7 | * @version: V1.0
|
| 8 | * @copyright:Copyright (c) MobileTek
|
| 9 | *
|
| 10 | *********************************************/
|
| 11 |
|
| 12 | #include <stdio.h>
|
| 13 | #include <stdlib.h>
|
| 14 | #include <string.h>
|
| 15 | #include <sys/types.h>
|
| 16 | #include <errno.h>
|
| 17 | #include <sys/stat.h>
|
| 18 | #include <fcntl.h>
|
| 19 | #include <sys/ioctl.h>
|
| 20 | #include <dirent.h>
|
| 21 | #include <getopt.h>
|
| 22 | #include <unistd.h>
|
| 23 |
|
| 24 | #ifdef __cplusplus
|
| 25 | extern "C" {
|
| 26 | #endif
|
| 27 |
|
| 28 | #include "include/lynq-qser-fota.h"
|
| 29 | #include "liblog/lynq_deflog.h"
|
| 30 |
|
| 31 |
|
| 32 | #define USER_LOG_TAG "LYNQ_FOTA"
|
| 33 |
|
| 34 |
|
| 35 | #define SYSTEM_A "34650"
|
| 36 | #define SYSTEM_B "39019"
|
| 37 |
|
| 38 | char path[] = {0};
|
| 39 |
|
| 40 | #define BOOTABLE "45227"
|
| 41 | #define UNBOOTABLE "47806"
|
| 42 |
|
| 43 |
|
l.yang | 6e54791 | 2023-08-14 16:56:48 +0800 | [diff] [blame^] | 44 | #define LYNQ_UPGRADE_STATUS_VERIFING (0)
|
| 45 | #define LYNQ_UPGRADE_STATUS_VERIFY_SUCCESS (1)
|
| 46 | #define LYNQ_UPGRADE_STATUS_VERIFY_FAIL (2)
|
| 47 | #define LYNQ_UPGRADE_STATUS_UPDATING (3)
|
| 48 | #define LYNQ_UPGRADE_STATUS_UPDATE_SUCCESS (4)
|
| 49 | #define LYNQ_UPGRADE_STATUS_UPDATE_FAIL (5)
|
| 50 |
|
| 51 |
|
| 52 |
|
l.yang | 7d7b51c | 2023-08-04 17:02:48 +0800 | [diff] [blame] | 53 | typedef struct
|
| 54 | {
|
| 55 | int system;
|
| 56 | int status;
|
| 57 | int try_cnt;
|
| 58 | } z_system_info_t;
|
| 59 |
|
| 60 | typedef struct
|
| 61 | {
|
| 62 | int upgrade_status;
|
| 63 | int total_size;
|
| 64 | int upgraded_size;
|
| 65 | } z_upgrade_status_info_t;
|
| 66 |
|
| 67 | typedef struct
|
| 68 | {
|
| 69 | int boot_to;
|
| 70 | int fota_status;
|
| 71 | z_system_info_t system_1;
|
| 72 | z_system_info_t system_2;
|
| 73 | } z_upgrade_system_info_t;
|
| 74 |
|
| 75 | typedef struct
|
| 76 | {
|
| 77 | z_upgrade_status_info_t *status;
|
| 78 | void(* status_cb)(z_upgrade_status_info_t *status);
|
| 79 | } z_upgrade_flush_status_t;
|
| 80 |
|
| 81 | extern int zxic_dual_verify();
|
| 82 | extern int zxic_dual_upgrade(z_upgrade_flush_status_t *flush_status);
|
| 83 | extern int zxic_dual_get_upgrade_status(z_upgrade_status_info_t *upgrade_info);
|
| 84 | extern int zxic_dual_get_current_system();
|
| 85 | extern int zxic_dual_get_boot_to_system();
|
| 86 | extern int zxic_dual_set_boot_to_system(int system, int reboot_flag);
|
| 87 | extern int zxic_dual_get_system_status(z_upgrade_system_info_t *system_info);
|
| 88 | extern int zxic_dual_set_system_status(int system, int status);
|
| 89 | extern int zxic_dual_get_fota_status_for_nv();
|
| 90 | extern int zxic_dual_set_fota_status_for_nv(int status);
|
| 91 | extern int zxic_dual_sync_system(void);
|
| 92 | extern int zxic_dual_get_upgrade_type(void);
|
| 93 | extern void zxic_dual_get_sync_status(int *sync_status);
|
| 94 | extern int zxic_dual_set_sync_status(int sync_status);
|
| 95 | extern int zxic_dual_config_package_path(char *upgrade_package_path, int length);
|
| 96 |
|
| 97 | int lynq_fota_verify();
|
| 98 | int lynq_fota_upgrade();
|
| 99 | int lynq_get_current_system();
|
| 100 | int lynq_get_boot_to_system();
|
| 101 | int lynq_set_boot_to_system(char *option_para);
|
| 102 | int lynq_set_system_a_status(char *option_para);
|
| 103 | int lynq_set_system_b_status(char *option_para);
|
| 104 | int lynq_sync_system();
|
| 105 | int lynq_get_upgrade_type();
|
| 106 | int lynq_get_sync_status();
|
| 107 | int lynq_set_sync_status(char *option_para);
|
| 108 |
|
| 109 |
|
| 110 | /*****************************************
|
| 111 | * @brief:rock_update_main
|
| 112 | * @param count [IN]:NA
|
| 113 | * @param sum [OUT]:NA
|
| 114 | * @return :success 0, failed -1
|
| 115 | * @todo:NA
|
| 116 | * @see:NA
|
| 117 | * @warning:NA
|
| 118 | ******************************************/
|
| 119 | int rock_update_main(int reboot_flag)
|
| 120 | {
|
| 121 |
|
| 122 | int ret = 0;
|
| 123 | int current_slot = 0;
|
| 124 |
|
| 125 | ret = lynq_fota_verify();
|
| 126 | if(ret != 0)
|
| 127 | {
|
| 128 | LYINFLOG("Verify package failed exit upgrade");
|
| 129 | return -1;
|
| 130 | }
|
| 131 |
|
| 132 |
|
| 133 | LYINFLOG("-----Begin to upgrade ----");
|
| 134 | ret = lynq_fota_upgrade();
|
| 135 | if(ret != 0)
|
| 136 | {
|
| 137 | LYINFLOG("Fota upgrade failed!!!");
|
| 138 | return -1;
|
| 139 | }
|
| 140 |
|
| 141 | ret = lynq_get_upgrade_status();
|
l.yang | 6e54791 | 2023-08-14 16:56:48 +0800 | [diff] [blame^] | 142 | if(ret != LYNQ_UPGRADE_STATUS_UPDATE_SUCCESS)
|
l.yang | 7d7b51c | 2023-08-04 17:02:48 +0800 | [diff] [blame] | 143 | {
|
| 144 | LYINFLOG("Upgrade failed ");
|
| 145 | return -1;
|
| 146 | }
|
| 147 |
|
| 148 | current_slot = lynq_get_current_system();
|
| 149 | if(current_slot < 0)
|
| 150 | {
|
| 151 | LYINFLOG("Get current system failed");
|
| 152 | return -1;
|
| 153 | }
|
| 154 |
|
| 155 |
|
| 156 | if(current_slot == atoi(SYSTEM_A))
|
| 157 | {
|
| 158 | LYINFLOG("current system is system a");
|
| 159 |
|
| 160 |
|
| 161 | ret = lynq_set_boot_to_system((char *)SYSTEM_B);
|
| 162 | if(ret != 0)
|
| 163 | {
|
| 164 | LYINFLOG("set system B boot failed ");
|
| 165 | return -1;
|
| 166 | }
|
| 167 |
|
| 168 |
|
| 169 | ret = lynq_set_system_a_status((char *)UNBOOTABLE);
|
| 170 | if(ret < 0)
|
| 171 | {
|
| 172 | LYINFLOG("Set system A status to [%s] error ", UNBOOTABLE);
|
| 173 | return -1;
|
| 174 | }
|
| 175 |
|
| 176 | ret = lynq_set_system_b_status((char *)BOOTABLE);
|
| 177 | if(ret < 0)
|
| 178 | {
|
| 179 | LYINFLOG("Set system B status to [%s] error ", BOOTABLE);
|
| 180 | return -1;
|
| 181 | }
|
| 182 |
|
| 183 | }
|
| 184 | else if( current_slot == atoi(SYSTEM_B))
|
| 185 | {
|
| 186 | LYINFLOG("current system is system a");
|
| 187 |
|
| 188 |
|
| 189 | ret = lynq_set_boot_to_system((char *)SYSTEM_A);
|
| 190 | if(ret != 0)
|
| 191 | {
|
| 192 | LYINFLOG("set system B boot failed ");
|
| 193 | return -1;
|
| 194 | }
|
| 195 |
|
| 196 |
|
| 197 | ret = lynq_set_system_b_status((char *)UNBOOTABLE);
|
| 198 | if(ret < 0)
|
| 199 | {
|
| 200 | LYINFLOG("Set system B status to [%s] error ", UNBOOTABLE);
|
| 201 | return -1;
|
| 202 | }
|
| 203 |
|
| 204 | ret = lynq_set_system_a_status((char *)BOOTABLE);
|
| 205 | if(ret < 0)
|
| 206 | {
|
| 207 | LYINFLOG("Set system A status to [%s] error ", BOOTABLE);
|
| 208 | return -1;
|
| 209 | }
|
| 210 |
|
| 211 | }
|
| 212 |
|
| 213 | if(reboot_flag == 1)
|
| 214 | {
|
| 215 | LYINFLOG("Enter reboot device");
|
| 216 | system("reboot");
|
| 217 | }
|
| 218 |
|
| 219 | return 0;
|
| 220 | }
|
| 221 |
|
| 222 | /*****************************************
|
| 223 | * @brief:upgrade callback function
|
| 224 | * @param count [IN]:z_upgrade_status_info_t *p_status
|
| 225 | * @param sum [OUT]:NA
|
| 226 | * @return :NA
|
| 227 | * @todo:
|
| 228 | * @see:NA
|
| 229 | * @warning:NA
|
| 230 | ******************************************/
|
| 231 | void lynq_g_flush_upgrade_status(z_upgrade_status_info_t *p_status)
|
| 232 | {
|
| 233 |
|
| 234 | LYINFLOG("Current status:%d ", p_status->upgrade_status);
|
| 235 |
|
| 236 | LYINFLOG("Total size:%d ", p_status->total_size);
|
| 237 |
|
| 238 | LYINFLOG("Updated size:%d ", p_status->upgraded_size);
|
| 239 | return ;
|
| 240 | }
|
| 241 |
|
| 242 | /*****************************************
|
| 243 | * @brief:lynq_fota_set_addr_value
|
| 244 | * @param count [IN]:char *path
|
| 245 | * @param sum [OUT]:
|
| 246 | * @return :success 0, failed -1
|
| 247 | * @todo:NA
|
| 248 | * @see:NA
|
| 249 | * @warning:NA
|
| 250 | ******************************************/
|
| 251 | int lynq_fota_set_addr_value(char *value,int size)
|
| 252 | {
|
| 253 | int ret =0;
|
| 254 |
|
| 255 | LYLOGSET(LOG_INFO);
|
| 256 | LYLOGEINIT(USER_LOG_TAG);
|
| 257 |
|
| 258 | if (NULL == value || size <= 0)
|
| 259 | {
|
| 260 | LYINFLOG("Bad package path!!!");
|
| 261 | return -1;
|
| 262 | }
|
| 263 | ret = zxic_dual_config_package_path(value, strlen(value));
|
| 264 | if(ret == -1)
|
| 265 | {
|
| 266 | LYINFLOG("Configure upgrade package path fail");
|
| 267 | return -1;
|
| 268 | }
|
| 269 |
|
| 270 | LYINFLOG("Configure upgrade package path success");
|
| 271 | return 0;
|
| 272 | }
|
| 273 |
|
| 274 |
|
| 275 | /*****************************************
|
| 276 | * @brief:lynq_fota_verify
|
| 277 | * @param count [IN]:NA
|
| 278 | * @param sum [OUT]:NA
|
| 279 | * @return :success 0, failed -1
|
| 280 | * @todo:NA
|
| 281 | * @see:NA
|
| 282 | * @warning:NA
|
| 283 | ******************************************/
|
| 284 | int lynq_fota_verify()
|
| 285 | {
|
| 286 | int ret = 0;
|
| 287 |
|
| 288 | LYINFLOG("-----Begin to verify upgrade package----");
|
| 289 | ret = zxic_dual_verify();
|
| 290 | if(ret != 0)
|
| 291 | {
|
| 292 | LYINFLOG("Verify upgrade package failed");
|
| 293 | return -1;
|
| 294 | }
|
| 295 |
|
| 296 | return 0;
|
| 297 |
|
| 298 | }
|
| 299 |
|
| 300 | /*****************************************
|
| 301 | * @brief:upgrade function
|
| 302 | * @param count [IN]:NA
|
| 303 | * @param sum [OUT]:NA
|
| 304 | * @return :success 0, failed -1
|
| 305 | * @todo:NA
|
| 306 | * @see:NA
|
| 307 | * @warning:NA
|
| 308 | ******************************************/
|
| 309 | int lynq_fota_upgrade()
|
| 310 | {
|
| 311 | int ret = 0;
|
| 312 | z_upgrade_flush_status_t flush_status;
|
| 313 | z_upgrade_status_info_t status;
|
| 314 | memset(&status, 0, sizeof(z_upgrade_status_info_t));
|
| 315 | flush_status.status = &status;
|
| 316 | flush_status.status_cb = &lynq_g_flush_upgrade_status;
|
| 317 |
|
| 318 |
|
| 319 | LYINFLOG("Enter lynq_fota_upgrade !!!!");
|
| 320 | ret = zxic_dual_upgrade(&flush_status);
|
| 321 | if(ret != 0)
|
| 322 | {
|
| 323 | LYINFLOG("Fota upgrade failed!!!");
|
| 324 | return -1;
|
| 325 | }
|
| 326 | return 0;
|
| 327 | }
|
| 328 |
|
| 329 | /*****************************************
|
| 330 | * @brief:lynq_fota_nrestart no reboot
|
| 331 | * @param count [IN]:NA
|
| 332 | * @param sum [OUT]:NA
|
| 333 | * @return :success 0, failed -1
|
| 334 | * @todo:NA
|
| 335 | * @see:NA
|
| 336 | * @warning:NA
|
| 337 | ******************************************/
|
| 338 | int lynq_fota_nrestart(void)
|
| 339 | {
|
| 340 | int ret = 0;
|
| 341 | ret = rock_update_main(0);
|
| 342 | if(ret != 0)
|
| 343 | {
|
| 344 | LYINFLOG("Upgrade failed !!!!");
|
| 345 | return -1;
|
| 346 | }
|
| 347 | else
|
| 348 | {
|
| 349 | LYINFLOG("upgrade success!!!");
|
| 350 | }
|
| 351 | return 0;
|
| 352 | }
|
| 353 |
|
| 354 | /*****************************************
|
| 355 | * @brief:lynq_rock_main,upgrade done reboot
|
| 356 | * @param count [IN]:int first_run
|
| 357 | * @param sum [OUT]:NA
|
| 358 | * @return :success 0, failed -1
|
| 359 | * @todo:NA
|
| 360 | * @see:NA
|
| 361 | * @warning:NA
|
| 362 | ******************************************/
|
| 363 | int lynq_rock_main(int first_run)
|
| 364 | {
|
| 365 | if(first_run <= 0)
|
| 366 | {
|
| 367 | LYINFLOG("Bad input value !!!");
|
| 368 | return -1;
|
| 369 | }
|
| 370 |
|
| 371 | int ret = 0;
|
| 372 | ret = rock_update_main(1);
|
| 373 | LYINFLOG("rock_update_main ret = %d\n", ret);
|
| 374 | if(ret != 0)
|
| 375 | {
|
| 376 | LYINFLOG("fota update fail!\n");
|
| 377 | }
|
| 378 | return 0;
|
| 379 |
|
| 380 | }
|
| 381 |
|
| 382 | /*****************************************
|
| 383 | * @brief:lynq_get_current_system
|
| 384 | * @param count [IN]:NA
|
| 385 | * @param sum [OUT]:NA
|
| 386 | * @return :success: curretn slot , failed:-1
|
| 387 | * @todo:NA
|
| 388 | * @see:NA
|
| 389 | * @warning:NA
|
| 390 | ******************************************/
|
| 391 | int lynq_get_current_system()
|
| 392 | {
|
| 393 | int ret = 0;
|
| 394 |
|
| 395 | ret = zxic_dual_get_current_system();
|
| 396 | if(ret < 0)
|
| 397 | {
|
| 398 | LYINFLOG("lynq get current system faile");
|
| 399 | return -1;
|
| 400 | }
|
| 401 | if(ret == 34650)
|
| 402 | {
|
| 403 | LYINFLOG("Get current system is system A");
|
| 404 | }
|
| 405 | else if(ret == 39019)
|
| 406 | {
|
| 407 | LYINFLOG("Get current system is system B");
|
| 408 | }
|
| 409 |
|
| 410 | return ret;
|
| 411 |
|
| 412 | }
|
| 413 |
|
| 414 | /*****************************************
|
| 415 | * @brief:lynq_get_boot_to_system
|
| 416 | * @param count [IN]:NA
|
| 417 | * @param sum [OUT]:NA
|
| 418 | * @return :success: 0, failed:-1
|
| 419 | * @todo:NA
|
| 420 | * @see:NA
|
| 421 | * @warning:NA
|
| 422 | ******************************************/
|
| 423 | int lynq_get_boot_to_system()
|
| 424 | {
|
| 425 | int boot_to = 0;
|
| 426 | boot_to = zxic_dual_get_boot_to_system();
|
| 427 | if(boot_to < 0)
|
| 428 | {
|
| 429 | LYINFLOG("lynq get boot to system failed");
|
| 430 | return -1;
|
| 431 | }
|
| 432 | else
|
| 433 | {
|
| 434 | LYINFLOG("Boot to system:0x%08X[%d]",boot_to);
|
| 435 | }
|
| 436 |
|
| 437 | return 0;
|
| 438 |
|
| 439 | }
|
| 440 |
|
| 441 | /*****************************************
|
| 442 | * @brief:lynq_set_boot_to_system
|
| 443 | * @param count [IN]:char *option_para
|
| 444 | * @param sum [OUT]:NA
|
| 445 | * @return :success: 0, failed:-1
|
| 446 | * @todo:NA
|
| 447 | * @see:NA
|
| 448 | * @warning:NA
|
| 449 | ******************************************/
|
| 450 | int lynq_set_boot_to_system(char *option_para)
|
| 451 | {
|
| 452 | int ret = 0;
|
| 453 | if(option_para == NULL)
|
| 454 | {
|
| 455 | LYINFLOG("Input invalid value! null option parameters! ");
|
| 456 | return -1;
|
| 457 | }
|
| 458 |
|
| 459 | ret = zxic_dual_set_boot_to_system(atoi(option_para), 0);
|
| 460 | if(ret < 0)
|
| 461 | {
|
| 462 | LYINFLOG("Set boot to [%s] error ", option_para);
|
| 463 | return -1;
|
| 464 | }
|
| 465 |
|
| 466 | return 0;
|
| 467 | }
|
| 468 |
|
| 469 | /*****************************************
|
| 470 | * @brief:lynq_get_upgrade_status
|
| 471 | * @param count [IN]:NA
|
| 472 | * @param sum [OUT]:NA
|
| 473 | * @return :success: 0, failed:-1
|
| 474 | * @todo:NA
|
| 475 | * @see:NA
|
| 476 | * @warning:NA
|
| 477 | ******************************************/
|
| 478 | int lynq_get_upgrade_status(void)
|
| 479 | {
|
| 480 | z_upgrade_status_info_t status;
|
| 481 | int ret = 0;
|
| 482 |
|
| 483 |
|
| 484 | ret = zxic_dual_get_upgrade_status(&status);
|
| 485 | if(ret < 0)
|
| 486 | {
|
| 487 | LYINFLOG("Get upgrade status fail! ");
|
| 488 | return -1;
|
| 489 | }
|
| 490 |
|
| 491 | LYINFLOG("Current upgrade info: ");
|
| 492 | LYINFLOG("Current upgrade status:%d ", status.upgrade_status);
|
| 493 | LYINFLOG("Current upgrade total size:%d ", status.total_size);
|
| 494 | LYINFLOG("Current upgrade updated size:%d ", status.upgraded_size);
|
l.yang | 6e54791 | 2023-08-14 16:56:48 +0800 | [diff] [blame^] | 495 |
|
| 496 | return status.upgrade_status;
|
l.yang | 7d7b51c | 2023-08-04 17:02:48 +0800 | [diff] [blame] | 497 |
|
| 498 | }
|
| 499 |
|
| 500 | /*****************************************
|
| 501 | * @brief:lynq_get_upgrade_status
|
| 502 | * @param count [IN]:NA
|
| 503 | * @param sum [OUT]:NA
|
| 504 | * @return :success: 0, failed:-1
|
| 505 | * @todo:NA
|
| 506 | * @see:NA
|
| 507 | * @warning:NA
|
| 508 | ******************************************/
|
| 509 | int lynq_get_system_info()
|
| 510 | {
|
| 511 | int ret = 0;
|
| 512 | z_upgrade_system_info_t system_info;
|
| 513 |
|
| 514 | ret = zxic_dual_get_system_status(&system_info);
|
| 515 | if(ret < 0)
|
| 516 | {
|
| 517 | LYINFLOG("Get upgrade status fail! ");
|
| 518 | return -1;
|
| 519 | }
|
| 520 | else
|
| 521 | {
|
| 522 | LYINFLOG("System info: ");
|
| 523 | LYINFLOG("Boot to:0x%08X[%d] ", system_info.boot_to, system_info.boot_to);
|
| 524 | LYINFLOG("Fota status:%d ", system_info.fota_status);
|
| 525 | LYINFLOG("System1 system:0x%08X [%d] ", system_info.system_1.system, system_info.system_1.system);
|
| 526 | LYINFLOG("System1 status:%d ", system_info.system_1.status);
|
| 527 | LYINFLOG("System1 try_cnt:%d ", system_info.system_1.try_cnt);
|
| 528 | LYINFLOG("System2 system:0x%08X [%d] ", system_info.system_2.system, system_info.system_2.system);
|
| 529 | LYINFLOG("System2 status:%d ", system_info.system_2.status);
|
| 530 | LYINFLOG("System2 try_cnt:%d ", system_info.system_2.try_cnt);
|
| 531 | }
|
| 532 |
|
| 533 | return 0;
|
| 534 |
|
| 535 | }
|
| 536 |
|
| 537 | /*****************************************
|
| 538 | * @brief:lynq_set_system_a_status
|
| 539 | * @param count [IN]:char *option_para
|
| 540 | * @param sum [OUT]:NA
|
| 541 | * @return :success: 0, failed:-1
|
| 542 | * @todo:NA
|
| 543 | * @see:NA
|
| 544 | * @warning:NA
|
| 545 | ******************************************/
|
| 546 | int lynq_set_system_a_status(char *option_para)
|
| 547 | {
|
| 548 | int ret = -1;
|
| 549 | if (NULL == option_para)
|
| 550 | {
|
| 551 | LYINFLOG("Invalid option_para value ");
|
| 552 | return -1;
|
| 553 | }
|
| 554 |
|
| 555 | //34650 A slot status : bootable:45527 unbootalbe:47806 success:23579
|
| 556 | ret = zxic_dual_set_system_status(34650, atoi(option_para));
|
| 557 | if(ret < 0)
|
| 558 | {
|
| 559 | LYINFLOG("Set system 1 status to [%s] error ", option_para);
|
| 560 | return -1;
|
| 561 | }
|
| 562 |
|
| 563 | return 0;
|
| 564 |
|
| 565 | }
|
| 566 |
|
| 567 | /*****************************************
|
| 568 | * @brief:lynq_set_system_b_status
|
| 569 | * @param count [IN]:char *option_para
|
| 570 | * @param sum [OUT]:NA
|
| 571 | * @return :success: 0, failed:-1
|
| 572 | * @todo:NA
|
| 573 | * @see:NA
|
| 574 | * @warning:NA
|
| 575 | *****************************************/
|
| 576 | int lynq_set_system_b_status(char * option_para)
|
| 577 | {
|
| 578 | int ret = -1;
|
| 579 | if (NULL == option_para)
|
| 580 | {
|
| 581 | LYINFLOG("Invalid option_para value ");
|
| 582 | return -1;
|
| 583 | }
|
| 584 |
|
| 585 | //39019 B slot status: bootable:45227 unbootalbe:47806 success:23579
|
| 586 | ret = zxic_dual_set_system_status(39019, atoi(option_para));
|
| 587 | if(ret < 0)
|
| 588 | {
|
| 589 | LYINFLOG("Set system 2 status to [%s] error ", option_para);
|
| 590 | }
|
| 591 |
|
| 592 | return 0;
|
| 593 | }
|
| 594 |
|
| 595 | /*****************************************
|
| 596 | * @brief:lynq_get_fota_status_for_nv
|
| 597 | * @param count [IN]:NA
|
| 598 | * @param sum [OUT]:NA
|
| 599 | * @return :success: 0, failed:-1
|
| 600 | * @todo:NA
|
| 601 | * @see:NA
|
| 602 | * @warning:NA
|
| 603 | *****************************************/
|
| 604 | int lynq_get_fota_status_for_nv()
|
| 605 | {
|
| 606 | int status = 0;
|
| 607 | status = zxic_dual_get_fota_status_for_nv();
|
| 608 | if(status != 0)
|
| 609 | {
|
| 610 | LYINFLOG("Fota status:%d ", status);
|
| 611 | return -1;
|
| 612 | }
|
| 613 | return 0;
|
| 614 | }
|
| 615 |
|
| 616 | /*****************************************
|
| 617 | * @brief:lynq_set_fota_status_for_nv
|
| 618 | * @param count [IN]:char *option_para
|
| 619 | * @param sum [OUT]:NA
|
| 620 | * @return :success: 0, failed:-1
|
| 621 | * @todo:NA
|
| 622 | * @see:NA
|
| 623 | * @warning:NA
|
| 624 | *****************************************/
|
| 625 | int lynq_set_fota_status_for_nv(char * option_para)
|
| 626 | {
|
| 627 | int ret = 0;
|
| 628 |
|
| 629 | if (NULL == option_para)
|
| 630 | {
|
| 631 | LYINFLOG("Invalid value! null option parameters! ");
|
| 632 | return -1;
|
| 633 | }
|
| 634 |
|
| 635 | ret = zxic_dual_set_fota_status_for_nv(atoi(option_para));
|
| 636 | if(ret < 0)
|
| 637 | {
|
| 638 | LYINFLOG("Set fota_status to [%s] error ", option_para);
|
| 639 | }
|
| 640 |
|
| 641 | return ret;
|
| 642 | }
|
| 643 |
|
| 644 | /*****************************************
|
| 645 | * @brief:lynq_sync_system
|
| 646 | * @param count [IN]:char *option_para
|
| 647 | * @param sum [OUT]:NA
|
| 648 | * @return :success: 0, failed:-1
|
| 649 | * @todo:NA
|
| 650 | * @see:NA
|
| 651 | * @warning:NA
|
| 652 | *****************************************/
|
| 653 | int lynq_sync_system()
|
| 654 | {
|
| 655 | int ret = -1;
|
| 656 |
|
| 657 | ret = zxic_dual_sync_system();
|
| 658 | if( ret != 0)
|
| 659 | {
|
| 660 | LYINFLOG("lynq sync system failed !!!!");
|
| 661 | return -1;
|
| 662 | }
|
| 663 |
|
| 664 | return 0;
|
| 665 | }
|
| 666 |
|
| 667 | /*****************************************
|
| 668 | * @brief:lynq_get_upgrade_type
|
| 669 | * @param count [IN]:NA
|
| 670 | * @param sum [OUT]:NA
|
| 671 | * @return :success: 0, failed:-1
|
| 672 | * @todo:NA
|
| 673 | * @see:NA
|
| 674 | * @warning:NA
|
| 675 | *****************************************/
|
| 676 | int lynq_get_upgrade_type()
|
| 677 | {
|
| 678 | int upgrade_type = -1;
|
| 679 |
|
| 680 | upgrade_type = zxic_dual_get_upgrade_type();
|
| 681 | if(upgrade_type < 0)
|
| 682 | {
|
| 683 | LYINFLOG("Get upgrade type failed \n");
|
| 684 | return -1;
|
| 685 | }
|
| 686 | else
|
| 687 | {
|
| 688 | LYINFLOG("upgrade type is %d", upgrade_type);
|
| 689 | }
|
| 690 | return 0;
|
| 691 | }
|
| 692 |
|
| 693 | /*****************************************
|
| 694 | * @brief:lynq_get_sync_status
|
| 695 | * @param count [IN]:char *option_para
|
| 696 | * @param sum [OUT]:NA
|
| 697 | * @return :success: 0, failed:-1
|
| 698 | * @todo:NA
|
| 699 | * @see:NA
|
| 700 | * @warning:NA
|
| 701 | *****************************************/
|
| 702 | int lynq_get_sync_status()
|
| 703 | {
|
| 704 | int sync_status = -2;
|
| 705 | zxic_dual_get_sync_status(&sync_status);
|
| 706 | LYINFLOG("Current sync status is %d", sync_status);
|
| 707 | return 0;
|
| 708 | }
|
| 709 |
|
| 710 | /*****************************************
|
| 711 | * @brief:lynq_set_sync_status
|
| 712 | * @param count [IN]:char *option_para
|
| 713 | * @param sum [OUT]:NA
|
| 714 | * @return :success: 0, failed:-1
|
| 715 | * @todo:NA
|
| 716 | * @see:NA
|
| 717 | * @warning:NA
|
| 718 | *****************************************/
|
| 719 | int lynq_set_sync_status(char * option_para)
|
| 720 | {
|
| 721 | int ret = 0;
|
| 722 |
|
| 723 | if (NULL == option_para)
|
| 724 | {
|
| 725 | LYINFLOG("Command input invalid value! null option parameters! ");
|
| 726 | return -1;
|
| 727 | }
|
| 728 |
|
| 729 | ret = zxic_dual_set_sync_status(atoi(option_para));
|
| 730 | if (0 != ret)
|
| 731 | {
|
| 732 | LYINFLOG("set sync status fail");
|
| 733 | return -1;
|
| 734 | }
|
| 735 |
|
| 736 | return 0;
|
| 737 | }
|
| 738 |
|
| 739 |
|
| 740 | #ifdef __cplusplus
|
| 741 | }
|
| 742 | #endif
|
| 743 |
|