You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2022/08/25 13:24:57 UTC

[GitHub] [mynewt-nimble] michal-narajowski commented on a diff in pull request #1311: apps/bttester: add support for testing Periodic Advertising

michal-narajowski commented on code in PR #1311:
URL: https://github.com/apache/mynewt-nimble/pull/1311#discussion_r954963609


##########
apps/bttester/src/gap.c:
##########
@@ -1643,6 +1733,150 @@ static void set_filter_accept_list(const uint8_t *data, uint16_t len)
 		   			CONTROLLER_INDEX, status);
 }
 
+static void periodic_adv_configure(const uint8_t *data, uint16_t len)
+{
+    uint8_t status = BTP_STATUS_SUCCESS;
+	struct ble_gap_ext_adv_params ext_params = {0};
+    struct ble_gap_periodic_adv_params params = {0};
+    struct gap_periodic_adv_configure_cmd *cmd = (void *) data;
+	int rc;
+
+	memset(&params, 0, sizeof(params));
+    params.include_tx_power = cmd->include_tx_power;
+    params.itvl_min = cmd->itvl_min;
+    params.itvl_max = cmd->itvl_max;
+
+	ext_params.connectable = 0;
+	ext_params.scannable = 0;
+	ext_params.legacy_pdu = 0;
+	ext_params.anonymous = 0;
+	ext_params.own_addr_type = own_addr_type;
+	ext_params.primary_phy = BLE_HCI_LE_PHY_1M;
+	ext_params.secondary_phy = BLE_HCI_LE_PHY_1M;
+	ext_params.sid = 1;
+
+	rc = ble_gap_ext_adv_configure(1, &ext_params, NULL,
+								   gap_event_cb, NULL);
+	if (rc) {
+		SYS_LOG_ERR("Failed to configure extended advertiser; rc=%d", rc);
+		status = BTP_STATUS_FAILED;
+		goto rsp;
+	}
+
+	rc = ble_gap_periodic_adv_configure(1, &params);
+    if (rc) {
+		SYS_LOG_ERR("Failed to configure periodic advertiser; rc=%d\n params.itvl_min %d\n params.itvl_max %d\n", rc, params.itvl_min, params.itvl_max);

Review Comment:
   Fix formatting and too long line.



##########
apps/bttester/src/gap.c:
##########
@@ -1643,6 +1733,150 @@ static void set_filter_accept_list(const uint8_t *data, uint16_t len)
 		   			CONTROLLER_INDEX, status);
 }
 
+static void periodic_adv_configure(const uint8_t *data, uint16_t len)
+{
+    uint8_t status = BTP_STATUS_SUCCESS;
+	struct ble_gap_ext_adv_params ext_params = {0};
+    struct ble_gap_periodic_adv_params params = {0};
+    struct gap_periodic_adv_configure_cmd *cmd = (void *) data;
+	int rc;
+
+	memset(&params, 0, sizeof(params));
+    params.include_tx_power = cmd->include_tx_power;
+    params.itvl_min = cmd->itvl_min;
+    params.itvl_max = cmd->itvl_max;
+
+	ext_params.connectable = 0;
+	ext_params.scannable = 0;
+	ext_params.legacy_pdu = 0;
+	ext_params.anonymous = 0;
+	ext_params.own_addr_type = own_addr_type;
+	ext_params.primary_phy = BLE_HCI_LE_PHY_1M;
+	ext_params.secondary_phy = BLE_HCI_LE_PHY_1M;
+	ext_params.sid = 1;
+
+	rc = ble_gap_ext_adv_configure(1, &ext_params, NULL,
+								   gap_event_cb, NULL);
+	if (rc) {
+		SYS_LOG_ERR("Failed to configure extended advertiser; rc=%d", rc);
+		status = BTP_STATUS_FAILED;
+		goto rsp;
+	}
+
+	rc = ble_gap_periodic_adv_configure(1, &params);
+    if (rc) {
+		SYS_LOG_ERR("Failed to configure periodic advertiser; rc=%d\n params.itvl_min %d\n params.itvl_max %d\n", rc, params.itvl_min, params.itvl_max);
+        status = BTP_STATUS_FAILED;
+    }
+
+rsp:
+    tester_rsp(BTP_SERVICE_ID_GAP, GAP_PADV_CONFIGURE,
+               CONTROLLER_INDEX, status);
+}
+
+static void periodic_adv_start(const uint8_t *data, uint16_t len)
+{
+    uint8_t status = BTP_STATUS_SUCCESS;
+	int rc;
+
+
+	rc = ble_gap_ext_adv_start(1, 0, 0);
+	if (rc) {
+		SYS_LOG_ERR("Failed to start extended advertiser; rc=%d", rc);
+		status = BTP_STATUS_FAILED;
+	}
+
+	rc = ble_gap_periodic_adv_start(1);
+    if (rc) {
+		SYS_LOG_ERR("Failed to start periodic advertiser; rc=%d", rc);

Review Comment:
   Indentation.



##########
apps/bttester/src/gap.c:
##########
@@ -1643,6 +1733,150 @@ static void set_filter_accept_list(const uint8_t *data, uint16_t len)
 		   			CONTROLLER_INDEX, status);
 }
 
+static void periodic_adv_configure(const uint8_t *data, uint16_t len)
+{
+    uint8_t status = BTP_STATUS_SUCCESS;
+	struct ble_gap_ext_adv_params ext_params = {0};
+    struct ble_gap_periodic_adv_params params = {0};
+    struct gap_periodic_adv_configure_cmd *cmd = (void *) data;
+	int rc;
+
+	memset(&params, 0, sizeof(params));
+    params.include_tx_power = cmd->include_tx_power;
+    params.itvl_min = cmd->itvl_min;
+    params.itvl_max = cmd->itvl_max;
+
+	ext_params.connectable = 0;
+	ext_params.scannable = 0;
+	ext_params.legacy_pdu = 0;
+	ext_params.anonymous = 0;
+	ext_params.own_addr_type = own_addr_type;
+	ext_params.primary_phy = BLE_HCI_LE_PHY_1M;
+	ext_params.secondary_phy = BLE_HCI_LE_PHY_1M;
+	ext_params.sid = 1;
+
+	rc = ble_gap_ext_adv_configure(1, &ext_params, NULL,
+								   gap_event_cb, NULL);
+	if (rc) {
+		SYS_LOG_ERR("Failed to configure extended advertiser; rc=%d", rc);
+		status = BTP_STATUS_FAILED;
+		goto rsp;
+	}
+
+	rc = ble_gap_periodic_adv_configure(1, &params);
+    if (rc) {
+		SYS_LOG_ERR("Failed to configure periodic advertiser; rc=%d\n params.itvl_min %d\n params.itvl_max %d\n", rc, params.itvl_min, params.itvl_max);
+        status = BTP_STATUS_FAILED;
+    }
+
+rsp:
+    tester_rsp(BTP_SERVICE_ID_GAP, GAP_PADV_CONFIGURE,
+               CONTROLLER_INDEX, status);
+}
+
+static void periodic_adv_start(const uint8_t *data, uint16_t len)
+{
+    uint8_t status = BTP_STATUS_SUCCESS;
+	int rc;
+
+
+	rc = ble_gap_ext_adv_start(1, 0, 0);
+	if (rc) {
+		SYS_LOG_ERR("Failed to start extended advertiser; rc=%d", rc);
+		status = BTP_STATUS_FAILED;
+	}
+
+	rc = ble_gap_periodic_adv_start(1);
+    if (rc) {
+		SYS_LOG_ERR("Failed to start periodic advertiser; rc=%d", rc);
+        status = BTP_STATUS_FAILED;
+    }
+
+    tester_rsp(BTP_SERVICE_ID_GAP, GAP_PADV_START,
+               CONTROLLER_INDEX, status);
+}
+
+static void periodic_adv_set_data(const uint8_t *data, uint16_t len)
+{
+    uint8_t status = BTP_STATUS_SUCCESS;
+    struct os_mbuf *adv_data;
+    struct gap_periodic_adv_set_data_cmd *cmd = (void *) data;
+	int rc;
+
+    adv_data = os_msys_get_pkthdr(BLE_HCI_MAX_ADV_DATA_LEN, 0);
+    if (!adv_data) {
+        status = BTP_STATUS_FAILED;
+        goto rsp;
+    }
+
+    if (os_mbuf_append(adv_data, cmd->adv_data, cmd->adv_data_len)) {
+        status = BTP_STATUS_FAILED;
+        goto rsp;
+    }
+
+	rc = ble_gap_periodic_adv_set_data(1, adv_data);
+    if (rc) {
+		SYS_LOG_ERR("Failed to set periodic advertiser data; rc=%d", rc);
+        status = BTP_STATUS_FAILED;
+    }
+
+rsp:
+    tester_rsp(BTP_SERVICE_ID_GAP, GAP_PADV_SET_DATA,
+               CONTROLLER_INDEX, status);
+}
+
+static void periodic_adv_create_sync(const uint8_t *data, uint16_t len)
+{
+    uint8_t status = BTP_STATUS_SUCCESS;
+    struct gap_periodic_adv_create_sync_cmd *cmd = (void *) data;
+    struct ble_gap_periodic_sync_params params;
+	struct ble_gap_disc_params scan_params = {0};
+	int rc;
+
+    params.reports_disabled = cmd->reports_disabled;
+    params.skip = cmd->skip;
+    params.sync_timeout = cmd->sync_timeout;
+	SYS_LOG_DBG("\nreports_disabled %d\n skip %d \n sync_timeout %d\n", params.reports_disabled, params.skip, params.sync_timeout);

Review Comment:
   Indentation.



-- 
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: commits-unsubscribe@mynewt.apache.org

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