You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "ldube (via GitHub)" <gi...@apache.org> on 2023/06/03 14:23:54 UTC
[GitHub] [nuttx] ldube opened a new pull request, #9471: wireless/bluetooth: Add a generic access service.
ldube opened a new pull request, #9471:
URL: https://github.com/apache/nuttx/pull/9471
## Summary
Make NuttX peripheral visible to BLE apps.
## Impact
## Testing
MY .config contains:
CONFIG_DEVICE_NAME="Apache NuttX"
CONFIG_DEVICE_LOCAL_NAME="NuttX"
0) Use the nRF Connect app to scan and find NuttX device. NuttX is the default name.
Replace NuttX with the value you put in CONFIG_DEVICE_LOCAL_NAME.
1) The Complete Local Name field matches the CONFIG_DEVICE_LOCAL_NAME value.
2) Press connect.
3) The Device name value matches CONFIG_DEVICE_NAME. See image below.

--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] acassis commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218410035
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
@ldube could you please elaborate more about it:
"I would suggest that you delete any inaccurate comments instead of asking me to ignore them. It is hard to build trust online and you are not helping."
I think Petro was completely sure and honest on his suggestions. If he thought that the code was written from scratch by you, then you have all right to release it as Apache if you want to do so.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] ldube commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "ldube (via GitHub)" <gi...@apache.org>.
ldube commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1216873595
##########
wireless/bluetooth/Kconfig:
##########
@@ -60,6 +60,26 @@ menuconfig WIRELESS_BLUETOOTH_HOST
BLE link-layer or to an external device over HCI UART).
if WIRELESS_BLUETOOTH_HOST
+ config DEVICE_APPEARANCE
+ int "Appearance sub-category value"
+ default 0
+ range 0 5188
+ ---help---
+ This value comes from the "Appearance sub-category"
+ section (2.6.3) in the Bluetooth Assigned Numbers document.
+
+ config DEVICE_NAME
+ string "Device name"
+ default "Apache NuttX"
+ ---help---
+ The device name.
+
+ config DEVICE_LOCAL_NAME
+ string "Device local name"
+ default "NuttX"
+ ---help---
+ The device name used for advertising.
Review Comment:
Why are you removing the 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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] ldube commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "ldube (via GitHub)" <gi...@apache.org>.
ldube commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218321342
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
It is disappointing that I have to provide a "paper trail" to an open source project:
This change was inspired by the sample found in arduino101_firmware_source-v1.tar.bz2. The original file is: arduino101_firmware/external/zephyr/samples/bluetooth/peripheral/src/main.c.
The file is under the BSD license. Here is the first clause:
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
You must **RETAIN** the Copyright (c) 2016, Intel Corporation. That is how I read it. It has nothing to do with the year of creation. The creation already happened in 2016. I temporarily removed the other services with the intent of adding them back into the file later.
I would suggest that you delete any inaccurate comments instead of asking me to ignore them. It is hard to build trust online and you are not helping.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1216736777
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
Is it possible to contribute this under https://www.apache.org/licenses/LICENSE-2.0 ?
Also, is this file really created in 2016?
##########
wireless/bluetooth/Kconfig:
##########
@@ -60,6 +60,26 @@ menuconfig WIRELESS_BLUETOOTH_HOST
BLE link-layer or to an external device over HCI UART).
if WIRELESS_BLUETOOTH_HOST
+ config DEVICE_APPEARANCE
+ int "Appearance sub-category value"
+ default 0
+ range 0 5188
+ ---help---
+ This value comes from the "Appearance sub-category"
+ section (2.6.3) in the Bluetooth Assigned Numbers document.
+
+ config DEVICE_NAME
+ string "Device name"
+ default "Apache NuttX"
+ ---help---
+ The device name.
+
+ config DEVICE_LOCAL_NAME
+ string "Device local name"
+ default "NuttX"
+ ---help---
+ The device name used for advertising.
Review Comment:
```suggestion
config DEVICE_APPEARANCE
int "Appearance sub-category value"
default 0
range 0 5188
---help---
This value comes from the "Appearance sub-category"
section (2.6.3) in the Bluetooth Assigned Numbers document.
config DEVICE_NAME
string "Device name"
default "Apache NuttX"
---help---
The device name.
config DEVICE_LOCAL_NAME
string "Device local name"
default "NuttX"
---help---
The device name used for advertising.
```
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <string.h>
+#include <errno.h>
+#include <debug.h>
+#include <arpa/inet.h>
+#include <sys/param.h>
+
+#include <nuttx/wireless/bluetooth/bt_hci.h>
+#include <nuttx/wireless/bluetooth/bt_core.h>
+#include <nuttx/wireless/bluetooth/bt_uuid.h>
+#include <nuttx/wireless/bluetooth/bt_gatt.h>
+
+#include "bt_hcicore.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GASVC 0x0001
+#define NAME_CHR (GASVC + 0x0002)
+#define NAME_DSC (GASVC + 0x0003)
+#define APPEARANCE_CHR (GASVC + 0x0004)
+#define APPEARANCE_DSC (GASVC + 0x0005)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int read_appearance(FAR struct bt_conn_s *conn,
+ FAR const struct bt_gatt_attr_s *attr,
+ FAR void *buf,
+ uint8_t len,
+ uint16_t offset);
+
+static int read_name(FAR struct bt_conn_s *conn,
+ FAR const struct bt_gatt_attr_s *attr,
+ FAR void *buf,
+ uint8_t len,
+ uint16_t offset);
+
+static struct bt_uuid_s g_gap_uuid =
+{
+ .type = BT_UUID_16,
+ .u =
+ {
+ .u16 = BT_UUID_GAP
+ },
+};
+
+static struct bt_uuid_s g_device_name_uuid =
+{
+ .type = BT_UUID_16,
+ .u =
+ {
+ .u16 = BT_UUID_GAP_DEVICE_NAME,
+ }
+};
+
+static struct bt_gatt_chrc_s g_name_chrc =
+{
+ .properties = BT_GATT_CHRC_READ,
+ .value_handle = NAME_DSC,
+ .uuid = &g_device_name_uuid,
+};
+
+static struct bt_uuid_s g_appeareance_uuid =
+{
+ .type = BT_UUID_16,
+ .u =
+ {
+ .u16 = BT_UUID_GAP_APPEARANCE,
+ }
+};
+
+static struct bt_gatt_chrc_s g_appearance_chrc =
+{
+ .properties = BT_GATT_CHRC_READ,
+ .value_handle = APPEARANCE_DSC,
+ .uuid = &g_appeareance_uuid,
+};
+
+static const struct bt_gatt_attr_s g_attrs[] =
+{
+ BT_GATT_PRIMARY_SERVICE(GASVC, &g_gap_uuid),
+ BT_GATT_CHARACTERISTIC(NAME_CHR, &g_name_chrc),
+ BT_GATT_DESCRIPTOR(NAME_DSC, &g_device_name_uuid, BT_GATT_PERM_READ,
+ read_name, NULL, (void *)CONFIG_DEVICE_NAME),
Review Comment:
```suggestion
read_name, NULL, (FAR void *)CONFIG_DEVICE_NAME),
```
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <string.h>
+#include <errno.h>
+#include <debug.h>
+#include <arpa/inet.h>
+#include <sys/param.h>
+
+#include <nuttx/wireless/bluetooth/bt_hci.h>
+#include <nuttx/wireless/bluetooth/bt_core.h>
+#include <nuttx/wireless/bluetooth/bt_uuid.h>
+#include <nuttx/wireless/bluetooth/bt_gatt.h>
+
+#include "bt_hcicore.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GASVC 0x0001
+#define NAME_CHR (GASVC + 0x0002)
+#define NAME_DSC (GASVC + 0x0003)
+#define APPEARANCE_CHR (GASVC + 0x0004)
+#define APPEARANCE_DSC (GASVC + 0x0005)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int read_appearance(FAR struct bt_conn_s *conn,
+ FAR const struct bt_gatt_attr_s *attr,
+ FAR void *buf,
+ uint8_t len,
+ uint16_t offset);
+
+static int read_name(FAR struct bt_conn_s *conn,
+ FAR const struct bt_gatt_attr_s *attr,
+ FAR void *buf,
+ uint8_t len,
+ uint16_t offset);
+
+static struct bt_uuid_s g_gap_uuid =
+{
+ .type = BT_UUID_16,
+ .u =
+ {
+ .u16 = BT_UUID_GAP
+ },
+};
+
+static struct bt_uuid_s g_device_name_uuid =
+{
+ .type = BT_UUID_16,
+ .u =
+ {
+ .u16 = BT_UUID_GAP_DEVICE_NAME,
+ }
+};
+
+static struct bt_gatt_chrc_s g_name_chrc =
+{
+ .properties = BT_GATT_CHRC_READ,
+ .value_handle = NAME_DSC,
+ .uuid = &g_device_name_uuid,
+};
+
+static struct bt_uuid_s g_appeareance_uuid =
+{
+ .type = BT_UUID_16,
+ .u =
+ {
+ .u16 = BT_UUID_GAP_APPEARANCE,
+ }
+};
+
+static struct bt_gatt_chrc_s g_appearance_chrc =
+{
+ .properties = BT_GATT_CHRC_READ,
+ .value_handle = APPEARANCE_DSC,
+ .uuid = &g_appeareance_uuid,
+};
+
+static const struct bt_gatt_attr_s g_attrs[] =
+{
+ BT_GATT_PRIMARY_SERVICE(GASVC, &g_gap_uuid),
+ BT_GATT_CHARACTERISTIC(NAME_CHR, &g_name_chrc),
+ BT_GATT_DESCRIPTOR(NAME_DSC, &g_device_name_uuid, BT_GATT_PERM_READ,
+ read_name, NULL, (void *)CONFIG_DEVICE_NAME),
+ BT_GATT_CHARACTERISTIC(APPEARANCE_CHR, &g_appearance_chrc),
+ BT_GATT_DESCRIPTOR(APPEARANCE_DSC, &g_appeareance_uuid,
+ BT_GATT_PERM_READ, read_appearance, NULL, NULL),
+};
+
+static const struct bt_eir_s g_ad[] =
+{
+ {
+ .len = 2,
+ .type = BT_EIR_FLAGS,
+ .data =
+ {
+ BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR
+ },
+ },
+ {
+ .len = 0,
+ .type = 0,
+ .data = "",
+ }
+};
+
+static const struct bt_eir_s g_sd[] =
+{
+ {
+ .len = 16,
+ .type = BT_EIR_NAME_COMPLETE,
+ .data = CONFIG_DEVICE_LOCAL_NAME,
+ },
+ {
+ .len = 0,
+ .type = 0,
+ .data = "",
+ }
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: read_name
+ *
+ * Description:
+ * Read callback for name descriptor.
+ *
+ * Returned Value:
+ * Zero in case of success or negative value in case of error.
+ *
+ ****************************************************************************/
+
+static int read_name(FAR struct bt_conn_s *conn,
+ FAR const struct bt_gatt_attr_s *attr,
+ FAR void *buf,
+ uint8_t len,
+ uint16_t offset)
+{
+ const char *name = attr->user_data;
Review Comment:
```suggestion
FAR const char *name = attr->user_data;
```
##########
include/nuttx/wireless/bluetooth/bt_core.h:
##########
@@ -217,4 +217,20 @@ static inline int bt_addr_le_to_str(FAR const bt_addr_le_t *addr, char *str,
* Public Function Prototypes
****************************************************************************/
+/****************************************************************************
+ * Name: bt_add_services
+ *
+ * Description:
+ * Register services and start advertising.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * Zero in case of success or negative value in case of error.
+ *
+ ****************************************************************************/
+
+int bt_add_services(void);
Review Comment:
In general I agree that services should be defined at application level, but currently I do not see infrastructure for that. Probably a proper `ioctl` service should be added to support it.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] ldube commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "ldube (via GitHub)" <gi...@apache.org>.
ldube commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1216873595
##########
wireless/bluetooth/Kconfig:
##########
@@ -60,6 +60,26 @@ menuconfig WIRELESS_BLUETOOTH_HOST
BLE link-layer or to an external device over HCI UART).
if WIRELESS_BLUETOOTH_HOST
+ config DEVICE_APPEARANCE
+ int "Appearance sub-category value"
+ default 0
+ range 0 5188
+ ---help---
+ This value comes from the "Appearance sub-category"
+ section (2.6.3) in the Bluetooth Assigned Numbers document.
+
+ config DEVICE_NAME
+ string "Device name"
+ default "Apache NuttX"
+ ---help---
+ The device name.
+
+ config DEVICE_LOCAL_NAME
+ string "Device local name"
+ default "NuttX"
+ ---help---
+ The device name used for advertising.
Review Comment:
Why are you removing the 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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1215667635
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <string.h>
+#include <errno.h>
+#include <debug.h>
+#include <arpa/inet.h>
+#include <sys/param.h>
+
+#include <nuttx/wireless/bluetooth/bt_hci.h>
+#include <nuttx/wireless/bluetooth/bt_core.h>
+#include <nuttx/wireless/bluetooth/bt_uuid.h>
+#include <nuttx/wireless/bluetooth/bt_gatt.h>
+
+#include "bt_hcicore.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define GASVC 0x0001
+#define NAME_CHR (GASVC + 0x0002)
+#define NAME_DSC (GASVC + 0x0003)
+#define APPEARANCE_CHR (GASVC + 0x0004)
+#define APPEARANCE_DSC (GASVC + 0x0005)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int read_appearance(FAR struct bt_conn_s *conn,
+ FAR const struct bt_gatt_attr_s *attr,
+ FAR void *buf,
+ uint8_t len,
+ uint16_t offset);
+
+static int read_name(FAR struct bt_conn_s *conn,
+ FAR const struct bt_gatt_attr_s *attr,
+ FAR void *buf,
+ uint8_t len,
+ uint16_t offset);
+
+static struct bt_uuid_s gap_uuid =
+{
+ .type = BT_UUID_16,
+ .u =
+ {
+ .u16 = BT_UUID_GAP
+ },
+};
+
+static struct bt_uuid_s device_name_uuid =
+{
+ .type = BT_UUID_16,
+ .u =
+ {
+ .u16 = BT_UUID_GAP_DEVICE_NAME,
+ }
+};
+
+static struct bt_gatt_chrc_s name_chrc =
+{
+ .properties = BT_GATT_CHRC_READ,
+ .value_handle = NAME_DSC,
+ .uuid = &device_name_uuid,
+};
+
+static struct bt_uuid_s appeareance_uuid =
+{
+ .type = BT_UUID_16,
+ .u =
+ {
+ .u16 = BT_UUID_GAP_APPEARANCE,
+ }
+};
+
+static struct bt_gatt_chrc_s appearance_chrc =
+{
+ .properties = BT_GATT_CHRC_READ,
+ .value_handle = APPEARANCE_DSC,
+ .uuid = &appeareance_uuid,
+};
+
+static const struct bt_gatt_attr_s attrs[] =
+{
+ BT_GATT_PRIMARY_SERVICE(GASVC, &gap_uuid),
+ BT_GATT_CHARACTERISTIC(NAME_CHR, &name_chrc),
+ BT_GATT_DESCRIPTOR(NAME_DSC, &device_name_uuid, BT_GATT_PERM_READ,
+ read_name, NULL, (void *)CONFIG_DEVICE_NAME),
+ BT_GATT_CHARACTERISTIC(APPEARANCE_CHR, &appearance_chrc),
+ BT_GATT_DESCRIPTOR(APPEARANCE_DSC, &appeareance_uuid,
+ BT_GATT_PERM_READ, read_appearance, NULL, NULL),
+};
+
+static const struct bt_eir_s ad[] =
+{
+ {
+ .len = 2,
+ .type = BT_EIR_FLAGS,
+ .data =
+ {
+ BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR
+ },
+ },
+ {
+ .len = 0,
+ .type = 0,
+ .data = "",
+ }
+};
+
+static const struct bt_eir_s sd[] =
Review Comment:
add g_ prefix for all global variable
##########
include/nuttx/wireless/bluetooth/bt_core.h:
##########
@@ -217,4 +217,20 @@ static inline int bt_addr_le_to_str(FAR const bt_addr_le_t *addr, char *str,
* Public Function Prototypes
****************************************************************************/
+/****************************************************************************
+ * Name: bt_add_services
+ *
+ * Description:
+ * Register services and start advertising.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * Zero in case of success or negative value in case of error.
+ *
+ ****************************************************************************/
+
+int bt_add_services(void);
Review Comment:
should we move the service to userspace?
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] ldube commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "ldube (via GitHub)" <gi...@apache.org>.
ldube commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1216866700
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
I have no legal training so I keep the license of the code I got inspiration from.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] acassis commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218410035
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
@ldube could you please elaborate more about it:
"I would suggest that you delete any inaccurate comments instead of asking me to ignore them. It is hard to build trust online and you are not helping."
I think Petro is completely fine and honest on his suggestions
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] acassis commented on pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#issuecomment-1576691614
Thank you! @ldube !!!
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218157713
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
I'm completely fine to keep code as is, but:
1. We should be Intel copyright if code is originally produced by Intel. If you are currently working at Intel and contribute this code on behalf of Intel, that is ok.
2. The year of creation. If you contribute a brand new file with 2016 that is fine to accept if the original file on your PC is from 2016.
I'm also not a legal expert, so asking the opinion of people that spent more time on learning legal issues.
We have a big heritage from the time when the project was moved to Apache, so I want to make sure that the project is under control of all new non-Apache licensed files.
Please ignore my comment if that is not relevant. I didn't intend to limit anyhow volunteers contributions. Thank you for pointing out other places. I will take a look.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218372916
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
Thank you for the explanation! I was confused by the term "inspired" and thought that you wrote the code by yourself. Of course the copied parts should be provided with a proper copyright notice.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] ldube commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "ldube (via GitHub)" <gi...@apache.org>.
ldube commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218107166
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
@pkarashchenko This is not the way to keep open source volunteers. I can change the license to Apache but it makes no difference in this case as long as the rest of the stack is BSD. The Kconfig: bool "Use components that have BSD licenses" is already in place to handle this. I am well-aware of open source licensing issues - been doing this for a while. I think you should put your efforts into replacing the NuttX files with the Apache licensed Zephyr stack circa 2018. That would be more productive.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218163893
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
@ldubeĀ thank you for your effort. I'm also volunteering to work on this project.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] ldube commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "ldube (via GitHub)" <gi...@apache.org>.
ldube commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218321342
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
It is disappointing that I have to provide a "paper trail" to an open source project:
This change was inspired by the sample found in arduino101_firmware_source-v1.tar.bz2. The original file is: arduino101_firmware/external/zephyr/samples/bluetooth/peripheral/src/main.c.
The file is under the BSD license. Here is the first clause:
```
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
```
You must **RETAIN** the Copyright (c) 2016, Intel Corporation. That is how I read it. It has nothing to do with the year of creation. The creation already happened in 2016. I temporarily removed the other services with the intent of adding them back into the file later.
I would suggest that you delete any inaccurate comments instead of asking me to ignore them. It is hard to build trust online and you are not helping.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] acassis merged pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis merged PR #9471:
URL: https://github.com/apache/nuttx/pull/9471
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] ldube commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "ldube (via GitHub)" <gi...@apache.org>.
ldube commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218321342
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
It is disappointing that I have to provide a "paper trail" to an open source project:
This change was inspired by the sample found in arduino101_firmware_source-v1.tar.bz2. The original file is: arduino101_firmware/external/zephyr/samples/bluetooth/peripheral/src/main.c.
The file is under the BSD license. Here is the first clause:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
You must **RETAIN** the Copyright (c) 2016, Intel Corporation. That is how I read it. It has nothing to do with the year of creation. The creation already happened in 2016. I temporarily removed the other services with the intent of adding them back into the file later.
I would suggest that you delete any inaccurate comments instead of asking me to ignore them. It is hard to build trust online and you are not helping.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1217624799
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
@btashton @jerpelea what is your opinion?
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1218372916
##########
wireless/bluetooth/bt_services.c:
##########
@@ -0,0 +1,241 @@
+/****************************************************************************
+ * wireless/bluetooth/bt_services.c
+ *
+ * Copyright (c) 2016, Intel Corporation
+ * All rights reserved.
Review Comment:
Thank you for the explanation! I was confused by the term "inspired by" and thought that you wrote the code by yourself. Of course the copied parts should be provided with a proper copyright notice.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] ldube commented on a diff in pull request #9471: wireless/bluetooth: Add a generic access service.
Posted by "ldube (via GitHub)" <gi...@apache.org>.
ldube commented on code in PR #9471:
URL: https://github.com/apache/nuttx/pull/9471#discussion_r1215691245
##########
include/nuttx/wireless/bluetooth/bt_core.h:
##########
@@ -217,4 +217,20 @@ static inline int bt_addr_le_to_str(FAR const bt_addr_le_t *addr, char *str,
* Public Function Prototypes
****************************************************************************/
+/****************************************************************************
+ * Name: bt_add_services
+ *
+ * Description:
+ * Register services and start advertising.
+ *
+ * Input Parameters:
+ * None
+ *
+ * Returned Value:
+ * Zero in case of success or negative value in case of error.
+ *
+ ****************************************************************************/
+
+int bt_add_services(void);
Review Comment:
I would say no, because I don't see the value and don't have the time or interest right now, but I am not against someone submitting a PR that proves me wrong.
--
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@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org