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/04/08 09:47:46 UTC

[GitHub] [mynewt-nimble] Reynevan94 opened a new pull request #794: Apps: add peripheral

Reynevan94 opened a new pull request #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794
 
 
   

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] sjanc commented on a change in pull request #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
sjanc commented on a change in pull request #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#discussion_r405988453
 
 

 ##########
 File path: apps/peripheral/src/main.c
 ##########
 @@ -0,0 +1,172 @@
+/*
+ * 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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "os/os.h"
+#include "sysinit/sysinit.h"
+#include "log/log.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "services/gap/ble_svc_gap.h"
+
+static uint8_t g_own_addr_type;
+static uint16_t conn_handle;
+static const char *device_name = "Mynewt";
+
+/* adv_event() calls advertise(), so forward declaration is required */
+static void advertise(void);
+
+static int
+adv_event(struct ble_gap_event *event, void *arg)
+{
+    switch (event->type) {
+    case BLE_GAP_EVENT_ADV_COMPLETE:
+        MODLOG_DFLT(INFO,"Advertising completed, termination code: %d\n",
+                    event->adv_complete.reason);
+        advertise();
+        break;
+    case BLE_GAP_EVENT_CONNECT:
+        MODLOG_DFLT(INFO, "connection %s; status=%d\n",
+                    event->connect.status == 0 ? "established" : "failed",
+                    event->connect.status);
+        if (event->connect.status != 0) {
+            /* Connection failed; resume advertising */
+            advertise();
+            conn_handle = 0;
+        } else {
+            conn_handle = event->connect.conn_handle;
+        }
+        break;
+    case BLE_GAP_EVENT_CONN_UPDATE_REQ:
+        /* connected device requests update of connection parameters,
+           and these are being filled in - NULL sets default values */
+        MODLOG_DFLT(INFO, "updating conncetion parameters...\n");
+        event->conn_update_req.conn_handle = conn_handle;
+        event->conn_update_req.peer_params = NULL;
+        MODLOG_DFLT(INFO, "connection parameters updated!\n");
+        break;
+    case BLE_GAP_EVENT_DISCONNECT:
+        MODLOG_DFLT(INFO, "disconnect; reason=%d\n",
+        event->disconnect.reason);
+
+        /* reset conn_handle */
+        conn_handle = BLE_HS_CONN_HANDLE_NONE;
+
+        /* Connection terminated; resume advertising */
+        advertise();
+        break;
+    default:
+        MODLOG_DFLT(ERROR, "Advertising event not handled,"
+                    "event code: %u\n", event->type);
+        break;
+    }
+    return 0;
+}
+
+static void
+advertise(void)
+{
+    int rc;
+
+    /* set adv parameters */
+    struct ble_gap_adv_params adv_params;
+    struct ble_hs_adv_fields fields;
+    /* advertising payload is split into advertising data and advertising
+       response, because all data cannot fit into single packet; name of device
+       is sent as response to scan request */
+    struct ble_hs_adv_fields rsp_fields;
+
+    /* fill all fields and parameters with zeros */
+    memset(&adv_params, 0, sizeof(adv_params));
+    memset(&fields, 0, sizeof(fields));
+    memset(&rsp_fields, 0, sizeof(rsp_fields));
+
+    adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
+    adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN;
+
+    fields.flags = BLE_HS_ADV_F_DISC_GEN |
+                   BLE_HS_ADV_F_BREDR_UNSUP;
+    fields.uuids128 = BLE_UUID128(BLE_UUID128_DECLARE(
+        0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+        0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff));
+    fields.num_uuids128 = 1;
+    fields.uuids128_is_complete = 0;;
+    fields.tx_pwr_lvl = BLE_HS_ADV_TX_PWR_LVL_AUTO;
+
+    rsp_fields.name = (uint8_t *)device_name;
+    rsp_fields.name_len = strlen(device_name);
+    rsp_fields.name_is_complete = 1;
+
+    rc = ble_gap_adv_set_fields(&fields);
+    assert(rc == 0);
+
+    rc = ble_gap_adv_rsp_set_fields(&rsp_fields);
+
+    MODLOG_DFLT(INFO,"Starting advertising...\n");
+
+    rc = ble_gap_adv_start(g_own_addr_type, NULL, 100,
+                      &adv_params, adv_event, NULL);
 
 Review comment:
   some indentation issues

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-610926423
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-610901730
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### apps/peripheral/src/main.c
   <details>
   
   ```diff
   @@ -78,10 +78,10 @@
        default:
            MODLOG_DFLT(ERROR, "Advertising event not handled,"
                        "event code: %u\n", event->type);
   -    	break;
   +        break;
        }
        return 0;
   -}                                                                                                                                 
   +}
    
    static void
    advertise(void)
   @@ -116,7 +116,7 @@
        rsp_fields.name = (uint8_t *)device_name;
        rsp_fields.name_len = strlen(device_name);
        rsp_fields.name_is_complete = 1;
   -    
   +
        rc = ble_gap_adv_set_fields(&fields);
        assert(rc == 0);
    
   ```
   
   </details>

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-610880529
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### apps/peripheral/src/main.c
   <details>
   
   ```diff
   @@ -53,14 +53,13 @@
                /* Connection failed; resume advertising */
                advertise();
                conn_handle = 0;
   -        }
   -        else {
   +        } else   {
                conn_handle = event->connect.conn_handle;
            }
            break;
        case BLE_GAP_EVENT_CONN_UPDATE_REQ:
            /* connected device requests update of connection parameters,
   -        and these are being filled in - NULL sets default values */
   +           and these are being filled in - NULL sets default values */
            MODLOG_DFLT(INFO, "updating conncetion parameters...\n");
            event->conn_update_req.conn_handle = conn_handle;
            event->conn_update_req.peer_params = NULL;
   @@ -71,18 +70,18 @@
            event->disconnect.reason);
    
            /* reset conn_handle */
   -        conn_handle = BLE_HS_CONN_HANDLE_NONE; 
   +        conn_handle = BLE_HS_CONN_HANDLE_NONE;
    
            /* Connection terminated; resume advertising */
            advertise();
   -        break; 
   +        break;
        default:
            MODLOG_DFLT(ERROR, "Advertising event not handled,"
                        "event code: %u\n", event->type);
   -    break;
   +        break;
        }
        return 0;
   -}                                                                                                                                 
   +}
    
    static void
    advertise(void)
   @@ -93,8 +92,8 @@
        struct ble_gap_adv_params adv_params;
        struct ble_hs_adv_fields fields;
        /* advertising payload is split into advertising data and advertising
   -    response, because all data cannot fit into single packet; name of device
   -    is sent as response to scan request */
   +       response, because all data cannot fit into single packet; name of device
   +       is sent as response to scan request */
        struct ble_hs_adv_fields rsp_fields;
    
        /*fill all fields and parameters with zeros*/
   @@ -103,7 +102,7 @@
        memset(&rsp_fields, 0, sizeof(rsp_fields));
    
        adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
   -    adv_params.disc_mode =  BLE_GAP_DISC_MODE_GEN;
   +    adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN;
    
        fields.flags = BLE_HS_ADV_F_DISC_GEN |
                       BLE_HS_ADV_F_BREDR_UNSUP;
   @@ -117,7 +116,7 @@
        rsp_fields.name = (uint8_t *)device_name;
        rsp_fields.name_len = strlen(device_name);
        rsp_fields.name_is_complete = 1;
   -    
   +
        rc = ble_gap_adv_set_fields(&fields);
        assert(rc == 0);
    
   @@ -130,7 +129,7 @@
        assert(rc == 0);
    }
    
   -static void 
   +static void
    on_sync(void)
    {
        int rc;
   @@ -150,10 +149,11 @@
        MODLOG_DFLT(INFO, "Resetting state; reason=%d\n", reason);
    }
    
   -int main(int argc, char **argv)
   +int
   +main(int argc, char **argv)
    {
        int rc;
   -    
   +
        /* Initialize all packages. */
        sysinit();
    
   ```
   
   </details>

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-611356432
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-610926423
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] sjanc commented on a change in pull request #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
sjanc commented on a change in pull request #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#discussion_r405989498
 
 

 ##########
 File path: apps/peripheral/src/main.c
 ##########
 @@ -0,0 +1,172 @@
+/*
+ * 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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "os/os.h"
+#include "sysinit/sysinit.h"
+#include "log/log.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "services/gap/ble_svc_gap.h"
+
+static uint8_t g_own_addr_type;
+static uint16_t conn_handle;
+static const char *device_name = "Mynewt";
+
+/* adv_event() calls advertise(), so forward declaration is required */
+static void advertise(void);
+
+static int
+adv_event(struct ble_gap_event *event, void *arg)
+{
+    switch (event->type) {
+    case BLE_GAP_EVENT_ADV_COMPLETE:
+        MODLOG_DFLT(INFO,"Advertising completed, termination code: %d\n",
+                    event->adv_complete.reason);
+        advertise();
+        break;
+    case BLE_GAP_EVENT_CONNECT:
+        MODLOG_DFLT(INFO, "connection %s; status=%d\n",
+                    event->connect.status == 0 ? "established" : "failed",
+                    event->connect.status);
+        if (event->connect.status != 0) {
 
 Review comment:
   hmm I don't think you can get error here when being peripheral that is not doing directed advertising. Maybe change this to assert?

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-610901730
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### apps/peripheral/src/main.c
   <details>
   
   ```diff
   @@ -78,10 +78,10 @@
        default:
            MODLOG_DFLT(ERROR, "Advertising event not handled,"
                        "event code: %u\n", event->type);
   -    	break;
   +        break;
        }
        return 0;
   -}                                                                                                                                 
   +}
    
    static void
    advertise(void)
   @@ -116,7 +116,7 @@
        rsp_fields.name = (uint8_t *)device_name;
        rsp_fields.name_len = strlen(device_name);
        rsp_fields.name_is_complete = 1;
   -    
   +
        rc = ble_gap_adv_set_fields(&fields);
        assert(rc == 0);
    
   ```
   
   </details>

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-611368392
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-611356432
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-611368392
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] sjanc merged pull request #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
sjanc merged pull request #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794
 
 
   

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-611385239
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] apache-mynewt-bot commented on issue #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on issue #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#issuecomment-610880529
 
 
   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### apps/peripheral/src/main.c
   <details>
   
   ```diff
   @@ -53,14 +53,13 @@
                /* Connection failed; resume advertising */
                advertise();
                conn_handle = 0;
   -        }
   -        else {
   +        } else   {
                conn_handle = event->connect.conn_handle;
            }
            break;
        case BLE_GAP_EVENT_CONN_UPDATE_REQ:
            /* connected device requests update of connection parameters,
   -        and these are being filled in - NULL sets default values */
   +           and these are being filled in - NULL sets default values */
            MODLOG_DFLT(INFO, "updating conncetion parameters...\n");
            event->conn_update_req.conn_handle = conn_handle;
            event->conn_update_req.peer_params = NULL;
   @@ -71,18 +70,18 @@
            event->disconnect.reason);
    
            /* reset conn_handle */
   -        conn_handle = BLE_HS_CONN_HANDLE_NONE; 
   +        conn_handle = BLE_HS_CONN_HANDLE_NONE;
    
            /* Connection terminated; resume advertising */
            advertise();
   -        break; 
   +        break;
        default:
            MODLOG_DFLT(ERROR, "Advertising event not handled,"
                        "event code: %u\n", event->type);
   -    break;
   +        break;
        }
        return 0;
   -}                                                                                                                                 
   +}
    
    static void
    advertise(void)
   @@ -93,8 +92,8 @@
        struct ble_gap_adv_params adv_params;
        struct ble_hs_adv_fields fields;
        /* advertising payload is split into advertising data and advertising
   -    response, because all data cannot fit into single packet; name of device
   -    is sent as response to scan request */
   +       response, because all data cannot fit into single packet; name of device
   +       is sent as response to scan request */
        struct ble_hs_adv_fields rsp_fields;
    
        /*fill all fields and parameters with zeros*/
   @@ -103,7 +102,7 @@
        memset(&rsp_fields, 0, sizeof(rsp_fields));
    
        adv_params.conn_mode = BLE_GAP_CONN_MODE_UND;
   -    adv_params.disc_mode =  BLE_GAP_DISC_MODE_GEN;
   +    adv_params.disc_mode = BLE_GAP_DISC_MODE_GEN;
    
        fields.flags = BLE_HS_ADV_F_DISC_GEN |
                       BLE_HS_ADV_F_BREDR_UNSUP;
   @@ -117,7 +116,7 @@
        rsp_fields.name = (uint8_t *)device_name;
        rsp_fields.name_len = strlen(device_name);
        rsp_fields.name_is_complete = 1;
   -    
   +
        rc = ble_gap_adv_set_fields(&fields);
        assert(rc == 0);
    
   @@ -130,7 +129,7 @@
        assert(rc == 0);
    }
    
   -static void 
   +static void
    on_sync(void)
    {
        int rc;
   @@ -150,10 +149,11 @@
        MODLOG_DFLT(INFO, "Resetting state; reason=%d\n", reason);
    }
    
   -int main(int argc, char **argv)
   +int
   +main(int argc, char **argv)
    {
        int rc;
   -    
   +
        /* Initialize all packages. */
        sysinit();
    
   ```
   
   </details>

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] sjanc commented on a change in pull request #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
sjanc commented on a change in pull request #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#discussion_r405988029
 
 

 ##########
 File path: apps/peripheral/pkg.yml
 ##########
 @@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+pkg.name: "apps/peripheral"
+pkg.type: app
+pkg.description: "Basic perihperal application"
+pkg.author: "Krzysztof Kopyściński krzysztof.kopyscinski@codecoup.pl"
+
+
+pkg.deps:
+    - "@apache-mynewt-core/kernel/os"
+    - "@apache-mynewt-core/sys/console/full"
+    - "@apache-mynewt-core/sys/log/full"
+    - "@apache-mynewt-core/sys/stats/full"
+    - "@apache-mynewt-core/sys/log/modlog"
+    - "@apache-mynewt-nimble/nimble/host"
+    - "@apache-mynewt-nimble/nimble/host/util/"
+    - "@apache-mynewt-nimble/nimble/host/services/gap"
+    - "@apache-mynewt-nimble/nimble/host/store/config"
+    - "@apache-mynewt-nimble/nimble/transport"
 
 Review comment:
   missing newline at the end

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


With regards,
Apache Git Services

[GitHub] [mynewt-nimble] sjanc commented on a change in pull request #794: Apps: add peripheral

Posted by GitBox <gi...@apache.org>.
sjanc commented on a change in pull request #794: Apps: add peripheral
URL: https://github.com/apache/mynewt-nimble/pull/794#discussion_r406007056
 
 

 ##########
 File path: apps/peripheral/src/main.c
 ##########
 @@ -0,0 +1,166 @@
+/*
+ * 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 <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "os/os.h"
+#include "sysinit/sysinit.h"
+#include "log/log.h"
+#include "host/ble_hs.h"
+#include "host/util/util.h"
+#include "services/gap/ble_svc_gap.h"
+
+static uint8_t g_own_addr_type;
+static uint16_t conn_handle;
+static const char *device_name = "Mynewt";
+
+/* adv_event() calls advertise(), so forward declaration is required */
+static void advertise(void);
+
+static int
+adv_event(struct ble_gap_event *event, void *arg)
+{
+    switch (event->type) {
+    case BLE_GAP_EVENT_ADV_COMPLETE:
+        MODLOG_DFLT(INFO,"Advertising completed, termination code: %d\n",
+                    event->adv_complete.reason);
+        advertise();
+        break;
+    case BLE_GAP_EVENT_CONNECT:
+        assert(event->connect.status != 0);
 
 Review comment:
   shouldn't this be status == 0 ?

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


With regards,
Apache Git Services