andrzej-kaczmarek commented on a change in pull request #14: ble service: Current Time Service URL: https://github.com/apache/mynewt-nimble/pull/14#discussion_r179067891
########## File path: nimble/host/services/cts/src/ble_svc_cts.c ########## @@ -0,0 +1,544 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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. + */ + +#include <assert.h> +#include <string.h> + +#include "sysinit/sysinit.h" +#include "syscfg/syscfg.h" +#include "host/ble_hs.h" +#include "host/ble_gap.h" +#include "services/cts/ble_svc_cts.h" +#include "datetime/datetime.h" + +/* To use for days AND hours if update more than 255 days ago */ +#define BLE_SVC_CTS_UPDATED_SINCE_A_LONG_TIME_AGO 255 + +#define BLE_SVC_CTS_ADJUST_REASON_MANUAL_TIME_UPDATE 1 +#define BLE_SVC_CTS_ADJUST_REASON_EXTERN_REFERENCE_TIME_UPDATE 2 +#define BLE_SVC_CTS_ADJUST_REASON_CHANGE_OF_TIMEZONE 4 +#define BLE_SVC_CTS_ADJUST_REASON_CHANGE_OF_DST 8 + +static bool ble_svc_cts_reference_time_was_used = false; +static uint64_t ble_svc_cts_reference_time_last_used = 0; +static uint8_t ble_svc_cts_adjust_reason = 0; + +/* Used as buffer */ +static struct { + uint8_t time_source; + uint8_t time_accuracy; + uint8_t days; + uint8_t hours; +} __attribute__((__packed__)) ble_svc_cts_reference_time_information = { + .time_source = BLE_SVC_CTS_TIME_SOURCE_UNKNOWN, + .time_accuracy = BLE_SVC_CTS_TIME_ACCURACY_UNKNOWN, + .days = BLE_SVC_CTS_UPDATED_SINCE_A_LONG_TIME_AGO, + .hours = BLE_SVC_CTS_UPDATED_SINCE_A_LONG_TIME_AGO, +}; Review comment: you should first declare struct and then define variable ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services