net: lwm2m: LwM2M object time resource update

Updated Timestamp resource default buffer type to time_t.

Signed-off-by: Juha Heiskanen <juha.heiskanen@nordicsemi.no>
This commit is contained in:
Juha Heiskanen 2022-10-06 13:16:08 +03:00 committed by Carles Cufí
parent 31bf99cbd2
commit e1e2228e9c
4 changed files with 10 additions and 7 deletions

View file

@ -48,8 +48,8 @@ static bool container_full[MAX_INSTANCE_COUNT];
static double low_threshold[MAX_INSTANCE_COUNT];
static bool container_empty[MAX_INSTANCE_COUNT];
static double average_fill_speed[MAX_INSTANCE_COUNT];
static int64_t forecast_full_date[MAX_INSTANCE_COUNT];
static int64_t forecast_empty_date[MAX_INSTANCE_COUNT];
static time_t forecast_full_date[MAX_INSTANCE_COUNT];
static time_t forecast_empty_date[MAX_INSTANCE_COUNT];
static bool container_out_of_location[MAX_INSTANCE_COUNT];
static bool container_out_of_position[MAX_INSTANCE_COUNT];

View file

@ -90,8 +90,8 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
/* resource state variables */
static uint8_t error_code_list[DEVICE_ERROR_CODE_MAX];
static int32_t time_temp;
static uint32_t time_offset;
static time_t time_temp;
static time_t time_offset;
static uint8_t binding_mode[DEVICE_STRING_SHORT];
/* only 1 instance of device object exists */
@ -170,7 +170,10 @@ static int current_time_post_write_cb(uint16_t obj_inst_id, uint16_t res_id,
bool last_block, size_t total_size)
{
if (data_len == 4U) {
time_offset = *(int32_t *)data - (int32_t)(k_uptime_get() / 1000);
time_offset = *(uint32_t *)data - (uint32_t)(k_uptime_get() / 1000);
return 0;
} else if (data_len == 8U) {
time_offset = *(time_t *)data - (time_t)(k_uptime_get() / 1000);
return 0;
}

View file

@ -42,7 +42,7 @@ static double longitude;
static double altitude;
static double radius;
static double speed;
static int32_t timestamp;
static time_t timestamp;
static struct lwm2m_engine_obj location;
static struct lwm2m_engine_obj_field fields[] = {

View file

@ -65,7 +65,7 @@ static double test_float;
static bool test_bool;
static struct lwm2m_objlnk test_objlnk;
static uint8_t test_opaque[TEST_OPAQUE_MAX_SIZE];
static int64_t test_time;
static time_t test_time;
static struct lwm2m_engine_obj_inst *test_obj_create(uint16_t obj_inst_id)
{