hms_manager.cxx 1.4 KB
#include <string>
#include <thread>
#include "uav_core.h"
#include "uav_logger.h"
#include "uav_platform.h"
#include "uav_data_type.h"
#include "uav_hms_manager.h"
#include "uav_sdk_app_info.h"

static void hmsInfoCallbackFunc(T_UAVHmsInfoTable hmsInfoTable)
{
    for (int i = 0; i < hmsInfoTable.hmsInfoNum; i++)
    {
        LOG_INFO("index {}: errorCode {}, componentIndex {}, errorLevel {}", i,
            hmsInfoTable.hmsInfo[i].errorCode, hmsInfoTable.hmsInfo[i].componentIndex, hmsInfoTable.hmsInfo[i].errorLevel);
    }
}

static void hms_manager_routine(void)
{
    UAV_HmsManager_Init();
    //wait register success
    if(false == wait_register_ready(100)){
        LOG_ERROR("waitHandShakeRegister failed");
        return;
    }

    UAV_HmsManager_RegHmsInfoCallback(hmsInfoCallbackFunc);
    while(1)
    {
        std::this_thread::sleep_for(std::chrono::seconds(1));
    }
}

int main(int argc, char *argv[])
{
    T_AUserInfo usrInfo;

    logger_init(std::string(argv[1]));
    if(false == uav_sdk_app_info_init(&usrInfo)) {
        LOG_ERROR("uav_sdk_app_info_init failed");
        return -1;
    }
    UAV_Core_Init(&usrInfo);
    UAV_Core_SetAlias("tracerV1");
    // UAV_Uart_Init("/dev/pts/20",115200);
    UAV_Network_Init(LOCALHOST_ETHERNET);

    std::thread hms_manager(hms_manager_routine);
    hms_manager.detach();

    return UAV_Core_ApplicationStart();
}