sjanc commented on a change in pull request #796:
URL: https://github.com/apache/mynewt-nimble/pull/796#discussion_r444799832



##########
File path: apps/central/src/main.c
##########
@@ -0,0 +1,211 @@
+/*
+ * 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 "sysinit/sysinit.h"
+#include "os/os.h"
+#include "console/console.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "console/console.h"
+#include "log/log.h"
+
+static uint8_t g_own_addr_type;
+
+static void
+ble_app_set_addr(void)
+{
+    ble_addr_t addr;
+    int rc;
+
+    /* generate new non-resolvable private address */
+    rc = ble_hs_id_gen_rnd(0, &addr);
+    assert(rc == 0);
+
+    /* set generated address */
+    rc = ble_hs_id_set_rnd(addr.val);
+    assert(rc == 0);
+}
+
+/* scan_event() calls scan(), so forward declaration is required */
+static void scan(void);
+
+/* connection has separate event handler from scan */
+static int
+conn_event(struct ble_gap_event *event, void *arg)
+{
+    int rc;
+
+    switch (event->type) {
+    case BLE_GAP_EVENT_CONNECT:
+        if (event->connect.status == 0) {
+            MODLOG_DFLT(INFO,"Connection was established\n");
+            /* For demonstrative purposes, try set PHY for established
+               conection; when done, wait 2 seconds and repeat scan */
+            rc = ble_gap_set_prefered_le_phy(event->connect.conn_handle,
+                                             BLE_GAP_LE_PHY_2M_MASK,
+                                             BLE_GAP_LE_PHY_2M_MASK,
+                                             BLE_GAP_LE_PHY_CODED_ANY);
+            if (rc == 0) {
+                MODLOG_DFLT(INFO,"PHY update successful\n");
+            } else {
+                MODLOG_DFLT(INFO,"PHY update failed\n");
+            }
+            /* Before calling scan() again, wait predefined time delay_ms.
+               This value has to be converted to ticks first before calling
+               os_time_delay() */
+            os_time_delay(os_time_ms_to_ticks32(2000));

Review comment:
       you are blocking host task with that, you should not do that
   
   I think for central app we can skip phy updates for now and just have 
separate sample for playing with PHY (where we could test all combinations, 
including asymetric)




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to