[riot-notifications] [RIOT-OS/RIOT] examples/nimble_gatt: extend application with ble characteristics (#10465)

Hauke Petersen notifications at github.com
Mon Mar 4 15:42:50 CET 2019


haukepetersen requested changes on this pull request.

Minor line length issues left, else all good, works as expected.

> +    puts("");
+
+    return rc;
+}
+
+static int gatt_svr_chr_access_device_info_model(
+        uint16_t conn_handle, uint16_t attr_handle,
+        struct ble_gatt_access_ctxt *ctxt, void *arg)
+{
+    puts("service 'device info: model' callback triggered");
+
+    (void) conn_handle;
+    (void) attr_handle;
+    (void) arg;
+
+    snprintf(str_answer, STR_ANSWER_BUFFER_SIZE, "You are running RIOT on a(n) %s board, which features a(n) %s MCU.", RIOT_BOARD, RIOT_MCU);

line length... Not sure if Murdock is even complaining about this by now :-)

> @@ -78,10 +174,154 @@ static void start_advertise(void)
     (void)rc;
 }
 
+static int gatt_svr_chr_access_device_info_manufacturer(
+        uint16_t conn_handle, uint16_t attr_handle,
+        struct ble_gatt_access_ctxt *ctxt, void *arg)
+{
+    puts("service 'device info: manufacturer' callback triggered");
+
+    (void) conn_handle;
+    (void) attr_handle;
+    (void) arg;
+
+    snprintf(str_answer, STR_ANSWER_BUFFER_SIZE, "This is RIOT! (Version: %s)\n", RIOT_VERSION);

line length

> +        }
+
+        puts("");
+
+        return rc;
+    }
+    else if (ble_uuid_cmp(ctxt->chr->uuid, readonly_uuid) == 0) {
+
+        puts("access to characteristic 'rw demo (read-only)'");
+
+        if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) {
+            char random_digit;
+            /* get random char between '0' and '9' */
+            random_digit = 48 + (rand() % 10);
+
+            snprintf(str_answer, STR_ANSWER_BUFFER_SIZE, "new random number: %c", random_digit);

and one more :-)

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10465#pullrequestreview-210170266
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190304/06d06e7d/attachment.html>


More information about the notifications mailing list