-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
452 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/** | ||
* @file ciot_ntp_data.h | ||
* @author your name (you@domain.com) | ||
* @brief | ||
* @version 0.1 | ||
* @date 2023-10-18 | ||
* | ||
* @copyright Copyright (c) 2023 | ||
* | ||
*/ | ||
|
||
#ifndef __CIOT_NTP_DATA__H__ | ||
#define __CIOT_NTP_DATA__H__ | ||
|
||
#include <inttypes.h> | ||
#include <time.h> | ||
|
||
#include "ciot_config.h" | ||
|
||
typedef enum __attribute__((packed)) | ||
{ | ||
HG_NTP_STATE_RESET, | ||
HG_NTP_STATE_COMPLETED, | ||
HG_NTP_STATE_IN_PROGRESS, | ||
} ciot_ntp_state_t; | ||
|
||
typedef enum __attribute__((packed)) | ||
{ | ||
CIOT_NTP_REQ_UNKNOWN, | ||
} ciot_ntp_req_id_t; | ||
|
||
typedef struct __attribute__((packed)) | ||
{ | ||
uint8_t op_mode; | ||
uint8_t sync_mode; | ||
uint32_t sync_interval; | ||
char timezone[16]; | ||
char server[CIOT_CONFIG_NTP_SERVERS_COUNT][64]; | ||
} ciot_ntp_cfg_t; | ||
|
||
typedef struct __attribute__((packed)) | ||
{ | ||
ciot_ntp_state_t state; | ||
time_t last_sync; | ||
uint16_t sync_count; | ||
uint8_t init :1; | ||
uint8_t sync :1; | ||
uint8_t reserve :6; | ||
} ciot_ntp_status_t; | ||
|
||
typedef union __attribute__((packed)) | ||
{ | ||
|
||
} ciot_ntp_req_data_u; | ||
|
||
typedef struct __attribute__((packed)) | ||
{ | ||
ciot_ntp_req_id_t id; | ||
ciot_ntp_req_data_u data; | ||
} ciot_ntp_req_t; | ||
|
||
typedef union __attribute__((packed)) | ||
{ | ||
#if CIOT_CONFIG_FEATURE_NTP | ||
ciot_ntp_cfg_t config; | ||
ciot_ntp_status_t status; | ||
ciot_ntp_req_t request; | ||
#endif | ||
} ciot_ntp_data_u; | ||
|
||
|
||
#endif //!__CIOT_NTP_DATA__H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/** | ||
* @file ciot_ota_data.h | ||
* @author your name (you@domain.com) | ||
* @brief | ||
* @version 0.1 | ||
* @date 2023-10-18 | ||
* | ||
* @copyright Copyright (c) 2023 | ||
* | ||
*/ | ||
|
||
#ifndef __CIOT_OTA_DATA__H__ | ||
#define __CIOT_OTA_DATA__H__ | ||
|
||
#include <inttypes.h> | ||
#include <stddef.h> | ||
|
||
#include "ciot_err.h" | ||
#include "ciot_config.h" | ||
|
||
typedef enum __attribute__((packed)) | ||
{ | ||
CIOT_OTA_STATE_ERROR=-1, | ||
CIOT_OTA_STATE_IDLE, | ||
CIOT_OTA_STATE_INIT, | ||
CIOT_OTA_STATE_IN_PROGRESS, | ||
CIOT_OTA_STATE_START, | ||
CIOT_OTA_STATE_CONNECTED, | ||
CIOT_OTA_STATE_CHECKING_DATA, | ||
CIOT_OTA_STATE_DECRYPTING, | ||
CIOT_OTA_STATE_FLASHING, | ||
CIOT_OTA_STATE_UPDATE_BOOT_PARTITION, | ||
CIOT_OTA_STATE_DONE, | ||
} ciot_ota_state_t; | ||
|
||
typedef enum __attribute__((packed)) | ||
{ | ||
CIOT_OTA_REQ_UNKNOWN, | ||
} ciot_ota_req_id_t; | ||
|
||
typedef struct __attribute__((packed)) | ||
{ | ||
char url[128]; | ||
uint8_t force :1; | ||
uint8_t encrypted :1; | ||
uint8_t restart :1; | ||
uint8_t reserverd :5; | ||
} ciot_ota_cfg_t; | ||
|
||
typedef struct __attribute__((packed)) | ||
{ | ||
ciot_ota_state_t state; | ||
ciot_err_t error; | ||
size_t image_size; | ||
size_t image_read; | ||
} ciot_ota_status_t; | ||
|
||
typedef union __attribute__((packed)) | ||
{ | ||
|
||
} ciot_ota_req_data_u; | ||
|
||
typedef struct __attribute__((packed)) | ||
{ | ||
ciot_ota_req_id_t id; | ||
ciot_ota_req_data_u data; | ||
} ciot_ota_req_t; | ||
|
||
typedef union __attribute__((packed)) | ||
{ | ||
#if CIOT_CONFIG_FEATURE_OTA | ||
ciot_ota_cfg_t config; | ||
ciot_ota_status_t status; | ||
ciot_ota_req_t request; | ||
#endif | ||
} ciot_ota_data_u; | ||
|
||
#endif //!__CIOT_OTA_DATA__H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.