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 2020/05/18 08:25:58 UTC

[GitHub] [mynewt-nimble] Reynevan94 commented on a change in pull request #796: Apps: central added

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



##########
File path: apps/central/src/main.c
##########
@@ -0,0 +1,190 @@
+/*
+ * 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;
+uint32_t delay_ms = 2000;
+os_time_t ticks;
+
+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 fully established\n");
+            /* Set PHY for established conection */
+            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, "rx and tx PHYs set to 2M\n");
+            } else {
+                MODLOG_DFLT(INFO, "failed to set rx and tx PHYs\n");
+            }
+            ble_gap_terminate(event->connect.conn_handle, 0x13);
+            os_time_ms_to_ticks(delay_ms, &ticks);

Review comment:
       That was simply overlooked and it's fixed now. os_time_delay(os_time_ms_to_ticks32(delay_ms)); works perfect




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