Creating Ble Service with Nrf connect

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 running two times. Do you know the problem? Below you can see all the codes.

5050.main_mwe.cpp

8182.blewrap.cpp

Parents
  • Hi Mark,

    Thank you for contacting DevZone at NordicSemi. 

    Based on the information you have provided; I have created the project including these files and settings.

    I changed few settings as per my DK (NRF52840DK). I could build, flash, and see the output from this project.

    Here is the output as seen on the NRF Terminal:

    Do you see the same output?

    What do you mean by "everything in the header file is running two times". What specifically you mean by this? You have a class defination and few functions defined in the header file.

    Can you please elaborate more on it (with example / output etc.)? Also, with is the expected output / behavior and what actually is happening.

    Regards,

    Naeem

  • Thank you for youre response. I have the same output as you. The problem is when I connect the device ( which called "Foo 000003") in de NRF connect app I will see two times a "Environmental Sensing". But I only make it once. I have test a code with only a "#include "blewrapper.h". Then i see 3 times a  "Environmental Sensing" in the NRF connect app. So it looked like something is going wrong with the includes. Do you know the solution for this?

  • Hi Mark,

    Thank you for explaining. 

    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. 

    So basically, I moved the structs, variables, and functionality 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).

    I am attaching the project folder and outputs for reference.

    c_297881_BLE.zip

    *I have used a nRF52840DK.

    Regards,

    Naeem

Reply Children
Related