You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@mynewt.apache.org by "szymon-czapracki (via GitHub)" <gi...@apache.org> on 2025/01/28 17:40:15 UTC

[PR] apps: bttester: Add notify multiple command [mynewt-nimble]

szymon-czapracki opened a new pull request, #1964:
URL: https://github.com/apache/mynewt-nimble/pull/1964

   Add functionality to utilize BTP notify multiple command.
   Existing notify handling parses non-existent data.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] apps: bttester: Implement notify / Remove set_mult [mynewt-nimble]

Posted by "sjanc (via GitHub)" <gi...@apache.org>.
sjanc commented on code in PR #1964:
URL: https://github.com/apache/mynewt-nimble/pull/1964#discussion_r2005214714


##########
apps/bttester/src/btp/btp_gatt.h:
##########
@@ -314,10 +314,11 @@ struct btp_gatt_change_database_cmd {
     uint8_t visibility;
 } __packed;
 
-#define BTP_GATT_SET_MULT_VALUE        0x20
-struct btp_gatt_set_mult_val_cmd {
+#define BTP_GATT_NOTIFY_MULTIPLE        0x21
+struct btp_gatt_notify_mult_val_cmd {
+    ble_addr_t addr;
     uint16_t count;
-    uint8_t data[0];
+    uint16_t data[0];

Review Comment:
   name this handles[0]



##########
apps/bttester/src/btp_gatt.c:
##########
@@ -1871,44 +1871,25 @@ notify_multiple(uint16_t conn_handle, void *arg)
 }
 
 static uint8_t
-set_mult(const void *cmd, uint16_t cmd_len,
-         void *rsp, uint16_t *rsp_len)
+notify_mult(const void *cmd, uint16_t cmd_len,
+            void *rsp, uint16_t *rsp_len)
 {
-    const struct btp_gatt_set_mult_val_cmd *cp = cmd;
-    struct ble_gatt_notif tuples[16];
-    int i;
-    int rc = 0;
-    int data_idx = 0;
-    uint16_t data_len;
+    const struct btp_gatt_notify_mult_val_cmd *cp = cmd;
     struct notify_mult_cb_data cb_data;
+    int i;
 
-    for (i = 0; i < cp->count; i++) {
-        tuples[i].handle = get_le16(cp->data + data_idx);
-        data_idx += 2;
-        tuples[i].value = ble_hs_mbuf_att_pkt();
-        if (tuples[i].value == NULL) {
-            rc = ENOMEM;
-            goto done;
-        }
-
-        data_len = get_le16(cp->data + data_idx);
-        data_idx += 2;
-
-        os_mbuf_append(tuples[i].value, cp->data + data_idx, data_len);
-        data_idx += data_len;
+    if (cp->count > sizeof(cb_data.handles)) {

Review Comment:
   while you are at is please also add size validations for btp command since it is declared BTP_HANDLER_LENGTH_VARIABLE
   
   if (cmd_len < sizeof(*cp) || cmd_len != (sizeof(*cp) + (le16toh(cp->count)) * sizeof(cp->handles[0])))) { return failed;}
   



##########
apps/bttester/src/btp_gatt.c:
##########
@@ -1871,44 +1871,25 @@ notify_multiple(uint16_t conn_handle, void *arg)
 }
 
 static uint8_t
-set_mult(const void *cmd, uint16_t cmd_len,
-         void *rsp, uint16_t *rsp_len)
+notify_mult(const void *cmd, uint16_t cmd_len,
+            void *rsp, uint16_t *rsp_len)
 {
-    const struct btp_gatt_set_mult_val_cmd *cp = cmd;
-    struct ble_gatt_notif tuples[16];
-    int i;
-    int rc = 0;
-    int data_idx = 0;
-    uint16_t data_len;
+    const struct btp_gatt_notify_mult_val_cmd *cp = cmd;
     struct notify_mult_cb_data cb_data;
+    int i;
 
-    for (i = 0; i < cp->count; i++) {
-        tuples[i].handle = get_le16(cp->data + data_idx);
-        data_idx += 2;
-        tuples[i].value = ble_hs_mbuf_att_pkt();
-        if (tuples[i].value == NULL) {
-            rc = ENOMEM;
-            goto done;
-        }
-
-        data_len = get_le16(cp->data + data_idx);
-        data_idx += 2;
-
-        os_mbuf_append(tuples[i].value, cp->data + data_idx, data_len);
-        data_idx += data_len;
+    if (cp->count > sizeof(cb_data.handles)) {

Review Comment:
   count is also le16



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] apps: bttester: Implement notify / Remove set_mult [mynewt-nimble]

Posted by "szymon-czapracki (via GitHub)" <gi...@apache.org>.
szymon-czapracki commented on code in PR #1964:
URL: https://github.com/apache/mynewt-nimble/pull/1964#discussion_r2007592804


##########
apps/bttester/src/btp_gatt.c:
##########
@@ -1871,44 +1871,25 @@ notify_multiple(uint16_t conn_handle, void *arg)
 }
 
 static uint8_t
-set_mult(const void *cmd, uint16_t cmd_len,
-         void *rsp, uint16_t *rsp_len)
+notify_mult(const void *cmd, uint16_t cmd_len,
+            void *rsp, uint16_t *rsp_len)
 {
-    const struct btp_gatt_set_mult_val_cmd *cp = cmd;
-    struct ble_gatt_notif tuples[16];
-    int i;
-    int rc = 0;
-    int data_idx = 0;
-    uint16_t data_len;
+    const struct btp_gatt_notify_mult_val_cmd *cp = cmd;
     struct notify_mult_cb_data cb_data;
+    int i;
 
-    for (i = 0; i < cp->count; i++) {
-        tuples[i].handle = get_le16(cp->data + data_idx);
-        data_idx += 2;
-        tuples[i].value = ble_hs_mbuf_att_pkt();
-        if (tuples[i].value == NULL) {
-            rc = ENOMEM;
-            goto done;
-        }
-
-        data_len = get_le16(cp->data + data_idx);
-        data_idx += 2;
-
-        os_mbuf_append(tuples[i].value, cp->data + data_idx, data_len);
-        data_idx += data_len;
+    if (cp->count > sizeof(cb_data.handles)) {

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] apps: bttester: Implement notify / Remove set_mult [mynewt-nimble]

Posted by "szymon-czapracki (via GitHub)" <gi...@apache.org>.
szymon-czapracki commented on code in PR #1964:
URL: https://github.com/apache/mynewt-nimble/pull/1964#discussion_r2007591097


##########
apps/bttester/src/btp/btp_gatt.h:
##########
@@ -314,10 +314,11 @@ struct btp_gatt_change_database_cmd {
     uint8_t visibility;
 } __packed;
 
-#define BTP_GATT_SET_MULT_VALUE        0x20
-struct btp_gatt_set_mult_val_cmd {
+#define BTP_GATT_NOTIFY_MULTIPLE        0x21
+struct btp_gatt_notify_mult_val_cmd {
+    ble_addr_t addr;
     uint16_t count;
-    uint8_t data[0];
+    uint16_t data[0];

Review Comment:
   Done



##########
apps/bttester/src/btp_gatt.c:
##########
@@ -1871,44 +1871,25 @@ notify_multiple(uint16_t conn_handle, void *arg)
 }
 
 static uint8_t
-set_mult(const void *cmd, uint16_t cmd_len,
-         void *rsp, uint16_t *rsp_len)
+notify_mult(const void *cmd, uint16_t cmd_len,
+            void *rsp, uint16_t *rsp_len)
 {
-    const struct btp_gatt_set_mult_val_cmd *cp = cmd;
-    struct ble_gatt_notif tuples[16];
-    int i;
-    int rc = 0;
-    int data_idx = 0;
-    uint16_t data_len;
+    const struct btp_gatt_notify_mult_val_cmd *cp = cmd;
     struct notify_mult_cb_data cb_data;
+    int i;
 
-    for (i = 0; i < cp->count; i++) {
-        tuples[i].handle = get_le16(cp->data + data_idx);
-        data_idx += 2;
-        tuples[i].value = ble_hs_mbuf_att_pkt();
-        if (tuples[i].value == NULL) {
-            rc = ENOMEM;
-            goto done;
-        }
-
-        data_len = get_le16(cp->data + data_idx);
-        data_idx += 2;
-
-        os_mbuf_append(tuples[i].value, cp->data + data_idx, data_len);
-        data_idx += data_len;
+    if (cp->count > sizeof(cb_data.handles)) {

Review Comment:
   Done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] apps: bttester: Implement notify / Remove set_mult [mynewt-nimble]

Posted by "sjanc (via GitHub)" <gi...@apache.org>.
sjanc merged PR #1964:
URL: https://github.com/apache/mynewt-nimble/pull/1964


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org