Bluetooth connexion issue

Hello community, 
I'm trying to implement BT service on my project to be able to connect with my phone 
for information my project displays data from sensors(BME280, INA219, MPU6050)  connected to my D-kit 
i'm using nrf connect V1.8.0 and NRF5340dk
i got inspired from this BT tutorial to create my services 
but in terms of BT connexion i don't get the device on my ophone when i scan devices around 
which means that connexion isn't established
and i got this message "Advertising failed to start (err-11)"
i will attach below my output display 

i tried to flash my D-kit directly but it didn't work 
and i tried to activate the BT but in vain too 
i tried to use this function


Can you guys help  by telling me what's wrong on this situation 
why can't i get the bt to advertise 
do i missing something on the main or on the activation 
by the way my prj.conf should be good and i will liked below
 


Can you help me with this please 
i will be very grateful 

  • Hi,

    I do not see your code, but I assume you print "Advertising failed to start" if bt_le_adv_start() returns an error (and in that case it is only natural that you are not able to see the device from your phone when scanning, as it does not advertise). bt_le_adv_start() returns -EAGAIN if Bluetooth is not ready, so without seeing your code my guess is that you call this function too early. If need to wait until Bluetooth is enabled (for instance by using a callback that you provide to the call to bt_enable(), as you can see form the beacon sample.

  • hi, 
    thank you for your reply 
    infact i checked my code and i'm calling the function in the right place 


    if you're wondering what hae put in my function bt_ready_data_data_data_data_work_work_work_work_fn
    i'm linking it below 


    if functions are being called in the right place, then what is making the BT service failing to advertise ?
    can you help me find out please 
    Kindly,

  • I see. However, there seems to only be one condition where -EAGAIN (-11) would be returned in the case of legacy/normal advertising, and that is when Bluetooth is not ready. I do not see from these snippets why this would be a problem, but could you check with bt_is_ready() before calling bt_le_adv_start()? If it is not, wait a bit before you try. Or just try first and if it returns -EAGAIN try again at a later point.

  • Hello,
    i tried to search for the function bt_le_is_ready but i can't find it no where 
    can you provide me with an example code where it's been used 
    thank you in advance 

  • Hi,

    There are a few things missing here, most can be ignored, but for instance my_service_send() and my_service_init() are used by not defined anywhere in this code. So I ignore that.

    There are quite a few other things to note though, and that makes me want to stress that you should ensure that your code builds without warnings. The warnings are there to help you. For instance, in bt_ready_data_data_data_data_work_work_work_work_fn() you have an err variable that is not initialized (so the content is meaningless), and you use that to figure out if BT initialization was successful or not. Which is clearly pointless. For this err to be meaningful, change the function to use int err as parameter, and remove the err variable you declare within (refer to for instance the beacon example in the SDK to see how it is done).

    When I remove most of your code which is not related to BT and do a quick clean-up, advertising starts without an error.

    Here is your stripped main.c file that works fine BT vise (advertising works and I am able to connect):

1 2 3