mynewt-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] jacobrosenthal commented on a change in pull request #901: ble service: Device Information Service
Date Mon, 12 Mar 2018 21:31:32 GMT
jacobrosenthal commented on a change in pull request #901: ble service: Device Information
Service
URL: https://github.com/apache/mynewt-core/pull/901#discussion_r173953401
 
 

 ##########
 File path: net/nimble/host/services/dis/src/ble_svc_dis.c
 ##########
 @@ -0,0 +1,249 @@
+/**
+ * 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 "host/ble_hs.h"
+#include "services/dis/ble_svc_dis.h"
+
+/* Device information */
+struct ble_svc_dis_data ble_svc_dis_data = { 0 };
+
+/* Access function */
+static int
+ble_svc_dis_access(uint16_t conn_handle, uint16_t attr_handle,
+                   struct ble_gatt_access_ctxt *ctxt, void *arg);
+
+static const struct ble_gatt_svc_def ble_svc_dis_defs[] = {
+    { /*** Service: Device Information Service (DIS). */
+        .type = BLE_GATT_SVC_TYPE_PRIMARY,
+        .uuid = BLE_UUID16_DECLARE(BLE_SVC_DIS_UUID16),
+        .characteristics = (struct ble_gatt_chr_def[]) { {
+#if (MYNEWT_VAL(BLE_SVC_DIS_MODEL_NUMBER_READ_PERM) >= 0)
+	    /*** Characteristic: Model Number String */
+            .uuid = BLE_UUID16_DECLARE(BLE_SVC_DIS_CHR_UUID16_MODEL_NUMBER),
+            .access_cb = ble_svc_dis_access,
+            .flags = BLE_GATT_CHR_F_READ |
+	             MYNEWT_VAL(BLE_SVC_DIS_MODEL_NUMBER_READ_PERM),
+        }, {
+#endif
+#if (MYNEWT_VAL(BLE_SVC_DIS_SERIAL_NUMBER_READ_PERM) >= 0)
+	    /*** Characteristic: Serial Number String */
+            .uuid = BLE_UUID16_DECLARE(BLE_SVC_DIS_CHR_UUID16_SERIAL_NUMBER),
+            .access_cb = ble_svc_dis_access,
+            .flags = BLE_GATT_CHR_F_READ |
+	             MYNEWT_VAL(BLE_SVC_DIS_SERIAL_NUMBER_READ_PERM),
+        }, {
+#endif
+#if (MYNEWT_VAL(BLE_SVC_DIS_HARDWARE_REVISION_READ_PERM) >= 0)
+	    /*** Characteristic: Hardware Revision String */
+            .uuid = BLE_UUID16_DECLARE(BLE_SVC_DIS_CHR_UUID16_HARDWARE_REVISION),
+            .access_cb = ble_svc_dis_access,
+            .flags = BLE_GATT_CHR_F_READ |
+	             MYNEWT_VAL(BLE_SVC_DIS_HARDWARE_REVISION_READ_PERM),
+        }, {
+#endif
+#if (MYNEWT_VAL(BLE_SVC_DIS_FIRMWARE_REVISION_READ_PERM) >= 0)
+	    /*** Characteristic: Firmware Revision String */
+            .uuid = BLE_UUID16_DECLARE(BLE_SVC_DIS_CHR_UUID16_FIRMWARE_REVISION),
+            .access_cb = ble_svc_dis_access,
+            .flags = BLE_GATT_CHR_F_READ |
+	             MYNEWT_VAL(BLE_SVC_DIS_FIRMWARE_REVISION_READ_PERM),
+        }, {
+#endif
+#if (MYNEWT_VAL(BLE_SVC_DIS_SOFTWARE_REVISION_READ_PERM) >= 0)
+	    /*** Characteristic: Software Revision String */
+            .uuid = BLE_UUID16_DECLARE(BLE_SVC_DIS_CHR_UUID16_SOFTWARE_REVISION),
+            .access_cb = ble_svc_dis_access,
+            .flags = BLE_GATT_CHR_F_READ |
+	             MYNEWT_VAL(BLE_SVC_DIS_SOFTWARE_REVISION_READ_PERM),
+        }, {
+#endif
+#if (MYNEWT_VAL(BLE_SVC_DIS_MANUFACTURER_NAME_READ_PERM) >= 0)
+	    /*** Characteristic: Manufacturer Name */
+            .uuid = BLE_UUID16_DECLARE(BLE_SVC_DIS_CHR_UUID16_MANUFACTURER_NAME),
+            .access_cb = ble_svc_dis_access,
+            .flags = BLE_GATT_CHR_F_READ |
+	             MYNEWT_VAL(BLE_SVC_DIS_MANUFACTURER_NAME_READ_PERM),
+        }, {
+#endif
+            0, /* No more characteristics in this service */
+        }, }
+    },
+
+    {
+        0, /* No more services. */
+    },
+};
+
+/**
+ * Simple write access callback for the device information service
 
 Review comment:
   *read access callback

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message