andrzej-kaczmarek commented on a change in pull request #819: Feature/blecsc 
app: Cycling Speed and Cadence app
URL: https://github.com/apache/mynewt-core/pull/819#discussion_r168956962
 
 

 ##########
 File path: apps/blecsc/src/gatt_svr.c
 ##########
 @@ -0,0 +1,404 @@
+/*
+ * 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 <stdio.h>
+#include <string.h>
+#include "host/ble_hs.h"
+#include "host/ble_uuid.h"
+#include "blecsc_sens.h"
+
+static const char *manuf_name = "Apache Mynewt";
+static const char *model_num = "Mynewt CSC Sensor";
+
+static const uint8_t csc_supported_sensor_locations[] = {
+    SENSOR_LOCATION_FRONT_WHEEL,
+    SENSOR_LOCATION_REAR_DROPOUT,
+    SENSOR_LOCATION_CHAINSTAY,
+    SENSOR_LOCATION_REAR_WHEEL
+};
+
+static uint8_t sensor_location = SENSOR_LOCATION_REAR_DROPOUT;
+static struct ble_csc_measurement_state * measurement_state;
+uint16_t csc_measurement_handle;
+uint16_t csc_control_point_handle;
+
+static int
+gatt_svr_chr_access_csc_measurement(uint16_t conn_handle, 
+                                    uint16_t attr_handle,
+                                    struct ble_gatt_access_ctxt *ctxt, 
+                                    void *arg);
+                                  
+static int
+gatt_svr_chr_access_csc_feature(uint16_t conn_handle, 
+                                uint16_t attr_handle,
+                                struct ble_gatt_access_ctxt *ctxt, 
+                                void *arg);                                  
+                                
+static int
+gatt_svr_chr_access_sensor_location(uint16_t conn_handle, 
+                                    uint16_t attr_handle,
+                                    struct ble_gatt_access_ctxt *ctxt, 
+                                    void *arg);
+                                  
+static int
+gatt_svr_chr_access_sc_control_point(uint16_t conn_handle, 
+                                     uint16_t attr_handle,
+                                     struct ble_gatt_access_ctxt *ctxt, 
+                                     void *arg);                               
        
+
+static int
+gatt_svr_chr_access_device_info(uint16_t conn_handle, 
+                                uint16_t attr_handle,
+                                struct ble_gatt_access_ctxt *ctxt, 
+                                void *arg);
+
+static const struct ble_gatt_svc_def gatt_svr_svcs[] = {
+    {
+        /* Service: Cycling Speed and Cadence */
+        .type = BLE_GATT_SVC_TYPE_PRIMARY,
+        .uuid = BLE_UUID16_DECLARE(GATT_CSC_UUID),
+        .characteristics = (struct ble_gatt_chr_def[]) { {
+            /* Characteristic: Cycling Speed and Cadence Measurement */
+            .uuid = BLE_UUID16_DECLARE(GATT_CSC_MEASUREMENT_UUID),
+            .access_cb = gatt_svr_chr_access_csc_measurement,
+            .val_handle = &csc_measurement_handle,
+            .flags = BLE_GATT_CHR_F_NOTIFY,
+        }, {
+            /* Characteristic: Cycling Speed and Cadence features */
+            .uuid = BLE_UUID16_DECLARE(GATT_CSC_FEATURE_UUID),
+            .access_cb = gatt_svr_chr_access_csc_feature,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            /* Characteristic: Sensor Location */
+            .uuid = BLE_UUID16_DECLARE(GATT_SENSOR_LOCATION_UUID),
+            .access_cb = gatt_svr_chr_access_sensor_location,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            /* Characteristic: SC Control Point*/
+            .uuid = BLE_UUID16_DECLARE(GATT_SC_CONTROL_POINT_UUID),
+            .access_cb = gatt_svr_chr_access_sc_control_point,
+            .val_handle = &csc_control_point_handle,
+            .flags = BLE_GATT_CHR_F_WRITE | BLE_GATT_CHR_F_INDICATE,
+        }, {          
+            0, /* No more characteristics in this service */
+        }, }
+    },
+
+    {
+        /* Service: Device Information */
+        .type = BLE_GATT_SVC_TYPE_PRIMARY,
+        .uuid = BLE_UUID16_DECLARE(GATT_DEVICE_INFO_UUID),
+        .characteristics = (struct ble_gatt_chr_def[]) { {
+            /* Characteristic: * Manufacturer name */
+            .uuid = BLE_UUID16_DECLARE(GATT_MANUFACTURER_NAME_UUID),
+            .access_cb = gatt_svr_chr_access_device_info,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            /* Characteristic: Model number string */
+            .uuid = BLE_UUID16_DECLARE(GATT_MODEL_NUMBER_UUID),
+            .access_cb = gatt_svr_chr_access_device_info,
+            .flags = BLE_GATT_CHR_F_READ,
+        }, {
+            0, /* No more characteristics in this service */
+        }, }
+    },
+
+    {
+        0, /* No more services */
+    },
+};
+
+static void 
+store_le32_as_u8_arr(uint32_t val, uint8_t * arr)
 
 Review comment:
   os/endian.h already defines get/put for le16, le32 and le64

----------------------------------------------------------------
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

Reply via email to