2019-11-19 07:39:21 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "log.h"
|
2019-11-21 02:53:27 +00:00
|
|
|
#include "ztp_config.h"
|
2019-11-19 07:39:21 +00:00
|
|
|
#include "restful.h"
|
|
|
|
#include "json_interface.h"
|
|
|
|
#include "err_code.h"
|
|
|
|
|
2019-11-21 02:53:27 +00:00
|
|
|
#define ZTP_ESN ("ace08484843")
|
|
|
|
#define ZTP_VERSION ("0.1")
|
2019-11-19 07:39:21 +00:00
|
|
|
|
2019-11-21 03:23:04 +00:00
|
|
|
void __onPost(void *pData, unsigned int size, const char *pReqUrl,
|
|
|
|
const char *pDlPath, const char *pTaskUuid, int iFinished, void *pUserData)
|
2019-11-19 07:39:21 +00:00
|
|
|
{
|
2019-11-20 07:12:15 +00:00
|
|
|
UNUSED(size);
|
|
|
|
UNUSED(pReqUrl);
|
|
|
|
UNUSED(pDlPath);
|
|
|
|
UNUSED(pTaskUuid);
|
|
|
|
UNUSED(iFinished);
|
|
|
|
UNUSED(pUserData);
|
|
|
|
|
2019-11-21 03:23:04 +00:00
|
|
|
LOG_EX(LOG_Info, "Post Result: %s\n", (char *)pData);
|
2019-11-19 07:39:21 +00:00
|
|
|
}
|
|
|
|
|
2019-11-21 03:23:04 +00:00
|
|
|
int main(int argc, char **argv)
|
2019-11-19 07:39:21 +00:00
|
|
|
{
|
|
|
|
int ret = ERR_OK;
|
2019-11-21 03:23:04 +00:00
|
|
|
const char *pJson;
|
2019-11-19 07:39:21 +00:00
|
|
|
AUTH_ZTH_REQ ztpReq;
|
|
|
|
|
|
|
|
IHW_InitLOG("ZTP", NULL, TRUE);
|
2019-11-21 02:53:27 +00:00
|
|
|
APP_BUILD_INFO("ZTP", ZTP_VERSION);
|
2019-11-19 07:39:21 +00:00
|
|
|
|
|
|
|
init_configure(DEVICE_ZTP_PATH);
|
|
|
|
|
|
|
|
memset(&ztpReq, 0, sizeof(AUTH_ZTH_REQ));
|
|
|
|
ztpReq.pESN = ZTP_ESN;
|
|
|
|
|
|
|
|
pJson = Struct2Json(&ztpReq, JE_AUTH_ZTP, FALSE, &ret);
|
|
|
|
|
|
|
|
if(pJson && ret == ERR_OK) {
|
|
|
|
http_post_request("https://xajhuang.com:3006/post", pJson, __onPost);
|
|
|
|
} else {
|
|
|
|
LOG_EX(LOG_Error, "Create JSON error: %d\n", ret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(pJson) {
|
2019-11-21 03:23:04 +00:00
|
|
|
free((void *)pJson);
|
2019-11-19 07:39:21 +00:00
|
|
|
}
|
|
|
|
|
2019-11-20 07:12:15 +00:00
|
|
|
load_dev_config(ZTP_ESN);
|
|
|
|
|
2019-11-21 03:19:07 +00:00
|
|
|
#ifdef MONITOR_ZTP_CFG_FILE
|
|
|
|
while(ret == ERR_OK){
|
|
|
|
usleep(1000);
|
|
|
|
}
|
|
|
|
#endif
|
2019-11-19 07:39:21 +00:00
|
|
|
|
|
|
|
IHW_WaitFinishLogout();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|