niobe/applications/app/TW208_Module_JYRTC/ntpUdp.h

45 lines
1.3 KiB
C
Executable File

/*
* Copyright (c) 2021 Talkweb Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef NTPUDP_H
#define NTPUDP_H
#include <stdio.h>
#include <unistd.h>
#include "ohos_init.h"
#include "cmsis_os2.h"
#include "los_typedef.h"
#include <time.h>
typedef enum {
YEAR_MONTH_DAY = 0,
HOUR_MIN_SEC,
YEAR_MONTH_DAY_HOUR_MIN_SEC,
TIME_MAX
} TIME_FORMAT;
#define READ_RECV_BUFFER_SIZE 50
BOOL GetThreadRunStatus();
void SetThreadRunStatus(BOOL status);
BOOL GetTimeTm(const char* hostname, const uint16_t port, struct tm* time_tm);
int64_t GetEpochTime();
char* GetEpochTimeString(TIME_FORMAT format, const char* hostname, uint16_t port);
uint32_t ReadPacket(char* buf, size_t len);
uint32_t GetIpByHostName(const char* hostname, uint8_t* ipAddr);
BOOL StartUdpConnect(const char* hostname, uint16_t port);
BOOL StopUdpConnect();
#endif