mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
Добавляем класс IoTRTC для организации взаимодействия с библиотекой iarduino_RTC
This commit is contained in:
@@ -41,7 +41,7 @@ enum TimerTask_t { WIFI_SCAN,
|
||||
TIME,
|
||||
TIME_SYNC,
|
||||
UPTIME,
|
||||
UDPP,
|
||||
UDP, //UDPP
|
||||
TIMES,
|
||||
PTASK };
|
||||
|
||||
|
||||
21
include/classes/IoTRTC.h
Normal file
21
include/classes/IoTRTC.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <Arduino.h>
|
||||
#include <iarduino_RTC.h>
|
||||
|
||||
class iarduino_RTC_NTP: public iarduino_RTC_BASE {
|
||||
public:
|
||||
iarduino_RTC_NTP();
|
||||
void begin(void);
|
||||
uint8_t funcReadTimeIndex(uint8_t i);
|
||||
void funcWriteTimeIndex(uint8_t i, uint8_t j);
|
||||
uint8_t funcConvertNumToCode (uint8_t i) {return ((i/10) << 4) + (i%10);}
|
||||
};
|
||||
|
||||
class IoTRTC : public iarduino_RTC {
|
||||
public:
|
||||
IoTRTC(uint8_t i, uint8_t j=SS, uint8_t k=SCK, uint8_t n=MOSI) : iarduino_RTC(i, j, k, n) {
|
||||
if (i == 0) objClass = new iarduino_RTC_NTP();
|
||||
};
|
||||
|
||||
~IoTRTC();
|
||||
};
|
||||
@@ -54,7 +54,7 @@ void asyncUdpInit() {
|
||||
|
||||
//будем отправлять каждые 30 секунд презентацию данного устройства
|
||||
ts.add(
|
||||
UDPP, 60000, [&](void*) {
|
||||
UDP, 60000, [&](void*) { //UDPP
|
||||
if (isNetworkActive()) {
|
||||
SerialPrint("i", F("UDP"), F("Broadcast device presentation"));
|
||||
asyncUdp.broadcastTo(getThisDevice().c_str(), 4210);
|
||||
|
||||
42
src/classes/IoTRTC.cpp
Normal file
42
src/classes/IoTRTC.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "classes/IoTRTC.h"
|
||||
|
||||
IoTRTC::~IoTRTC() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
iarduino_RTC_NTP::iarduino_RTC_NTP() {
|
||||
|
||||
}
|
||||
|
||||
void iarduino_RTC_NTP::begin(void) {
|
||||
|
||||
}
|
||||
|
||||
uint8_t iarduino_RTC_NTP::funcReadTimeIndex(uint8_t i) {
|
||||
static tm localTimeVar;
|
||||
if (i == 0) {
|
||||
Serial.println(F("Read time from system."));
|
||||
time_t timeNowVar;
|
||||
time(&timeNowVar);
|
||||
localTimeVar = *localtime(&timeNowVar);
|
||||
}
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0: return funcConvertNumToCode(localTimeVar.tm_sec);
|
||||
case 1: return funcConvertNumToCode(localTimeVar.tm_min);
|
||||
case 2: return funcConvertNumToCode(localTimeVar.tm_hour);
|
||||
case 3: return funcConvertNumToCode(localTimeVar.tm_mday);
|
||||
case 4: return funcConvertNumToCode(localTimeVar.tm_mon+1);
|
||||
case 5: return funcConvertNumToCode(localTimeVar.tm_year);
|
||||
case 6: return funcConvertNumToCode(localTimeVar.tm_wday);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void iarduino_RTC_NTP::funcWriteTimeIndex(uint8_t i, uint8_t j) {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user