From ea5d40ff206a959d8461d1d727fda424ca2d31c4 Mon Sep 17 00:00:00 2001 From: TinyOh Date: Thu, 7 Mar 2019 11:15:38 +0800 Subject: [PATCH] fix(api): version check pass while device name out of check table. --- src/mynteye/api/version_checker.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/mynteye/api/version_checker.cc b/src/mynteye/api/version_checker.cc index d958f35..71cfff8 100644 --- a/src/mynteye/api/version_checker.cc +++ b/src/mynteye/api/version_checker.cc @@ -34,6 +34,7 @@ const char* WARN_DESCRIPTION_F = const char* WARN_DESCRIPTION_S = "We suggest that you should update the SDK"; const char* PASS_DESCRIPTION = "pass"; +const char* PASS_OUTOF_TABLE_WARNING = "You're using a custom mynteye device"; /** firmware/sdk version matched table */ /**----device type-----sdk version---firmware version-----pass tag-----*/ @@ -112,11 +113,27 @@ STATUS_UNIT checkUnit(const std::string& sdkv, return ST_NOT_PASS; } +bool checkIfDeviceInTable(const std::string& devn) { + for (size_t i =0; + i < sizeof(FSVM_TABLE)/sizeof(firmware_version_match_table_unit); + i++) { + if (FSVM_TABLE[i].device_type == devn) { + return true; + } + } + return false; +} + bool checkFirmwareVersion(const std::shared_ptr api) { auto sdkv = api->GetSDKVersion(); auto devn = api->GetInfo(Info::DEVICE_NAME); auto firmv = api->GetInfo(Info::FIRMWARE_VERSION); + if (!checkIfDeviceInTable(devn)) { + LOG(WARNING) << PASS_OUTOF_TABLE_WARNING; + return true; + } + for (size_t i =0; i < sizeof(FSVM_TABLE)/sizeof(firmware_version_match_table_unit); i++) {