收藏官网首页
查看: 7503|回复: 2

求助NTP时间获取问题

1

主题

3

帖子

67

积分

注册会员

Rank: 2

积分
67
跳转到指定楼层
楼主
发表于 2018-5-24 09:46:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
汉枫LPB120模块
当模组连上机智云服务器后,通过
void gizwitsGetNTP(void)
{
    int32_t ret = 0;
    protocolCommon_t getNTP;
    gizProtocolHeadInit((protocolHead_t *)&getNTP);
    getNTP.head.cmd = CMD_GET_NTP;
    getNTP.head.sn = gizwitsProtocol.sn++;
    getNTP.head.len = exchangeBytes(sizeof(protocolCommon_t)-4);
    getNTP.sum = gizProtocolSum((uint8_t *)&getNTP, sizeof(protocolCommon_t));
    ret = uartWrite((uint8_t *)&getNTP, sizeof(protocolCommon_t));
    if(ret < 0)
    {
        GIZWITS_LOG("ERR[NTP]: uart write error %d \n", ret);
    }
    gizProtocolWaitAck((uint8_t *)&getNTP, sizeof(protocolCommon_t));
}

获取网络时间
/** Protocol network time structure */
typedef struct
{
    uint16_t year;
    uint8_t month;
    uint8_t day;
    uint8_t hour;
    uint8_t minute;
    uint8_t second;
    uint32_t ntp;
}protocolTime_t;
但是网络时间的结构体是protocolTime_t

我的问题:gizwitsGetNTP()函数没有对protocolTime_t时间结构体中元素的数据进行更新,如何获取获取到网络时间。
备注:非串口打印GIZWITS_LOG("WIFI_NTP : [%d-%d-%d %02d:%02d:%02d][%d] \n",ptime->year,ptime->month,ptime->day,ptime->hour,ptime->minute,ptime->second,ptime->ntp);
在我的UI界面上显示。没明白这个网络时间是如何获取更新的,求大神指教!

0

主题

212

帖子

982

积分

超级版主

Rank: 8Rank: 8

积分
982
沙发
发表于 2018-5-24 14:36:53 | 只看该作者
时间是通过串口从模组获取的。

13

主题

81

帖子

1241

积分

金牌会员

Rank: 6Rank: 6

积分
1241
板凳
发表于 2018-5-24 22:37:16 | 只看该作者
protocolTime_t sntp_time;        //定义时间结构体
gagentGetNTP(&sntp_time);        //读取时间
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

加入Q群 返回顶部

版权与免责声明 © 2006-2024 Gizwits IoT Technology Co., Ltd. ( 粤ICP备11090211号 )

快速回复 返回顶部 返回列表