I am a beginner I want to advertise for some time then go to sleep mode and wake up do some tasks like advertising and go to sleep mode again. Do all this process recursively please suggest to me some way of doing this.
Thanks in advance
I am a beginner I want to advertise for some time then go to sleep mode and wake up do some tasks like advertising and go to sleep mode again. Do all this process recursively please suggest to me some way of doing this.
Thanks in advance
gentle remainder please do reply
Hi,
Which SDK are you using (nRF5 SDK or nRFConnect SDK)? Regardless, most most application samples go to system on sleep mode whenever possible, and wake up on any events for tasks that should be done, and go back to sleep as soon as possible again. The exact methods differ between the SDK's, though.
If what you mean is send an advertising packet, then sleep, send an advertising packet again, this is the default behavior or virtually all Bluetooth peripheral examples. If you mean advertise (including the sleep) for a good duration of time, then stop advertising and wait a good period of time before you start advertising again you would need to time this (using for instance app_timer in nRF5 SDK or for instance a timer expiery function or similar in the nRF Connect SDK.
PS: You will normally get a reply from Nordic staff within the next Norwegian business day, but should not expect faster replies then that.
I am using nrfsdk 17.1.0. I have also done by using a timer actually, first of all, I had created a timer for getting value from the sensor in that timeout handler I had enabled i2c to get data from the sensor and stored it in the variable then disable it Then use another timer to start advertising but my devkit (nrf52832) is not advertising properly Suggest me a way to do this. I want the data to be taken from the sensor to advertise for some time then go to sleep wake up advertise data then go to sleep repeat this process. The below-mentioned code is for starting advertising in timeout handler
static void repeated_timer_handler(void * p_context) { ble_advertising_start(&m_advertising, BLE_ADV_MODE_FAST); }
Basically what you want do do is this:
Is that correct? This is a common use case.
For 4, the default behavior of most SDK examples is to sleep (sleep mode is entered when a interrupt/event has been processed by doing so in the main loop.
Regarding 3, advertising is by default periodic, and the device sleeps in between (unless it does something else). You just need to configure the advertising interval to whatever fits your application. That means that you should not call ble_advertising_start() from an application timer. Just call this once.
For 2, updating advertising data I suggest you refer to How to update advertising data dynamically using BLE Advertising library.
For 1, you need to handle the specific sensor yourself. There are TWI drivers and libraries in the SDK you can use, though. As you care about current consumption it makes sense to enable TWI, then read the data from the sensor, and disable TWI to save current.
This means that after you have configured everything and started to advertise (perhaps after getting the initial sensor reading), you just need a single repeated application timer where you:
I had used two app timers one for getting data from the sensor another for start advertising but my timer corresponding to the sensor is working perfect but the timer for start advertising is not advertising properly it works once or two times then got stuck what could be a possible mistake can you suggest me something.
I am using ble_app_template code as a base in that it advertises once then I had to press the reset button for advertising but my requirement is such that it should advertise itself in a periodic fashion for that I had used the timer so that it will call and start advertising but if I use only timer corresponding to advertise then it works perfect but with timer corresponding to sensor data it stops after advertising once or twice although times for both timers are different.
Thanks for replying