<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93494/creating-ble-service-with-nrf-connect</link><description>I have a problem to advertise a service. When I include a header file, an extra service is automatically created. It seems like that the service will be advertised twice. Everything in the main code is running once and everything in the header file is</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 05 Nov 2022 10:19:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93494/creating-ble-service-with-nrf-connect" /><item><title>RE: Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/thread/394255?ContentTypeID=1</link><pubDate>Sat, 05 Nov 2022 10:19:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8736de95-fad2-4e66-bd0d-7d22b5b49363</guid><dc:creator>markgordijn@inovo.nl</dc:creator><description>&lt;p&gt;You can close the ticket! I have no more query left. Thank you for the help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/thread/394245?ContentTypeID=1</link><pubDate>Fri, 04 Nov 2022 22:58:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be50ee10-cf7f-4b21-a457-e39bb21d3f46</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Welcome Mark.&lt;/p&gt;
&lt;p&gt;Do you have any further query on the case or I may close this ticket? Let me know please.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;br /&gt;Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/thread/393975?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2022 15:33:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cda7c71c-ef8f-476c-80a0-3e5a7421a1bc</guid><dc:creator>markgordijn@inovo.nl</dc:creator><description>&lt;p&gt;Thank you for youre response!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/thread/393941?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2022 14:19:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42d45a00-fc22-404d-b171-f1101f6d69a6</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi Mark,&lt;/p&gt;
&lt;p&gt;Thank you for explaining.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So yes, you are right, I was able to see it two times. Then I modified the header and source files, and now I can see it only one time.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;So basically, I moved the structs, variables, and functionality&amp;nbsp;from header file to the source file (temp and humidity buffers are kept as these are directly used by the main as well), while just kept class definition and prototypes in the header (it was giving me weird error regarding ssize_t even though I included types.h, nonetheless, I used _ssize_t).&lt;/p&gt;
&lt;p&gt;I am attaching the project folder and outputs for reference.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/output_5F00_terminal.PNG" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/connected.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/c_5F00_297881_5F00_BLE.zip"&gt;devzone.nordicsemi.com/.../c_5F00_297881_5F00_BLE.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;*I have used a nRF52840DK.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/thread/393870?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2022 12:47:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1ef01212-397d-4b48-bcd1-88bf676ef3d7</guid><dc:creator>markgordijn@inovo.nl</dc:creator><description>&lt;p&gt;Thank you for youre response. I have the same output as you. The problem is when I connect the device ( which called &amp;quot;Foo 000003&amp;quot;) in de NRF connect app&amp;nbsp;I will see two times a &amp;quot;Environmental Sensing&amp;quot;. But I only make it once. I have&amp;nbsp;test a code with only a &amp;quot;#include &amp;quot;blewrapper.h&amp;quot;.&amp;nbsp;Then i see 3 times a&amp;nbsp;&amp;nbsp;&lt;span&gt;&amp;quot;Environmental Sensing&amp;quot; in the NRF connect app. So it looked like something is going wrong with the includes. Do you know the solution for this?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/thread/393867?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2022 12:39:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a6d490b-290f-4d70-a834-ca95e0cc9941</guid><dc:creator>Naeem Maroof</dc:creator><description>&lt;p&gt;Hi Mark,&lt;/p&gt;
&lt;p&gt;Thank you for contacting DevZone at NordicSemi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Based on the information you have provided; I have created the project including these files and settings.&lt;/p&gt;
&lt;p&gt;I changed few settings as per my DK (NRF52840DK).&amp;nbsp;I could build, flash, and see the output from this project.&lt;/p&gt;
&lt;p&gt;Here is the output as seen on the NRF Terminal:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1667478727647v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Do you see the same output?&lt;/p&gt;
&lt;p&gt;What do you mean by &amp;quot;everything in the header file is running two times&amp;quot;.&amp;nbsp;What specifically you mean by this? You have a class defination and few functions defined in the header file.&lt;/p&gt;
&lt;p&gt;Can you please elaborate more on it (with example / output etc.)? Also, with is&amp;nbsp;the expected output / behavior and what actually is happening.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Naeem&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/thread/393797?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2022 08:02:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d55a960a-f260-4f03-ab7a-ecb598b6dd32</guid><dc:creator>markgordijn@inovo.nl</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(peripheral_hr_cpp C CXX)

target_sources(app PRIVATE
  src/main_mwe.cpp src/blewrap.h src/blewrap.cpp
  )

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And this is the cmakelist&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/thread/393796?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2022 08:02:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdc704c7-c69d-48e8-a629-63e092536aba</guid><dc:creator>markgordijn@inovo.nl</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52833_QIAA=y
CONFIG_ARM_MPU=y
CONFIG_HW_STACK_PROTECTION=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y

CONFIG_DEBUG_THREAD_INFO=n
CONFIG_DEBUG_OPTIMIZATIONS=n

# enable segger comm?
CONFIG_USE_SEGGER_RTT=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_STDOUT_CONSOLE=y

CONFIG_RTT_CONSOLE=y

CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
CONFIG_RTTI=y
CONFIG_LOG=y

CONFIG_MINIMAL_LIBC=n
CONFIG_CPLUSPLUS=y
CONFIG_STD_CPP11=y
CONFIG_NEWLIB_LIBC=y
CONFIG_LIB_CPLUSPLUS=y

# BLE
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DIS=y
CONFIG_BT_GATT_DYNAMIC_DB=y
CONFIG_BT_DEVICE_NAME=&amp;quot;Foo 000000&amp;quot;
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_DEVICE_NAME_MAX=11
#0x0540 = 1344 generic sensor 0x0552 =1362 multisensor
CONFIG_BT_DEVICE_APPEARANCE=1344
CONFIG_BT_DIS_PNP=n
CONFIG_BT_DEBUG_LOG=n
CONFIG_BT_HCI=y
CONFIG_BT_CTLR=y
CONFIG_BT_SMP=y
CONFIG_BT_SIGNING=y
CONFIG_BT_ATT_PREPARE_COUNT=5
# CONFIG_BT_IAS=y
CONFIG_BT_PRIVACY=y
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
CONFIG_BT_SETTINGS=n
CONFIG_SETTINGS=n
CONFIG_BT_BUF_ACL_TX_SIZE=64&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is the prj.config file&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Creating Ble Service with Nrf connect</title><link>https://devzone.nordicsemi.com/thread/393736?ContentTypeID=1</link><pubDate>Wed, 02 Nov 2022 16:19:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2dec5b5c-5c65-471e-bae4-77b7ba26264c</guid><dc:creator>markgordijn@inovo.nl</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifndef BLE_WRAP_H
#define BLE_WRAP_H

#include &amp;lt;settings/settings.h&amp;gt;
#include &amp;lt;bluetooth/bluetooth.h&amp;gt;
#include &amp;lt;bluetooth/hci.h&amp;gt;
#include &amp;lt;bluetooth/conn.h&amp;gt;
#include &amp;lt;bluetooth/uuid.h&amp;gt;
#include &amp;lt;bluetooth/gatt.h&amp;gt;

static char char_deviceName[11] = {&amp;#39;F&amp;#39;, &amp;#39;o&amp;#39;, &amp;#39;o&amp;#39;, &amp;#39; &amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;0&amp;#39;, &amp;#39;3&amp;#39;, &amp;#39;\0&amp;#39;};
static const struct bt_data ad[] = {
    BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
};

static uint8_t bufferTemperature[4];
static uint8_t bufferhumidity[4];

static struct bt_conn *connection;

static void connected(struct bt_conn *conn, uint8_t err)
{
    if(connection != NULL)
    {
        printk(&amp;quot;Connection already established\n&amp;quot;);
        return;
    }

    if (err)
    {
        printk(&amp;quot;Connection failed (err 0x%02x)\n&amp;quot;, err);
    }
    else
    {
        connection = conn;      
        printk(&amp;quot;Connected\n&amp;quot;);
    }
}

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
    printk(&amp;quot;Disconnected (reason 0x%02x)\n&amp;quot;, reason);
    connection = nullptr;   
}

BT_CONN_CB_DEFINE(conn_callbacks) = {
    .connected = connected,
    .disconnected = disconnected,
};

static struct bt_le_adv_param advertisingParam;

class BleWrap
{
public:
    static BleWrap *getInstance(void);
    ~BleWrap();
    void init();

    static ssize_t readBytes(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, uint16_t len, uint16_t offset);

protected:
    BleWrap(void);
    static BleWrap *_pInstance;
};

BT_GATT_SERVICE_DEFINE(tempHuMService,
                       BT_GATT_PRIMARY_SERVICE(BT_UUID_ESS),
                       BT_GATT_CHARACTERISTIC(BT_UUID_TEMPERATURE, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, BleWrap::readBytes, NULL, &amp;amp;bufferTemperature),
                       BT_GATT_CHARACTERISTIC(BT_UUID_HUMIDITY, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, BleWrap::readBytes, NULL, &amp;amp;bufferhumidity), );

#endif&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is the header file&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>