Sending single Advertisement package without an interval

nRF Connect SDK 1.9.1
nRF52805

Hello,

In my application I have two areas where much current is consumed (two current spikes). 

1. Getting values from external sensors

2. Sending signals in BLE advertisement packages

Due to optimization, I would like to synchronize this manually. 

I started with a main loop with 2sec sleep and periodic advertising with a 2 sec interval. ( two current spikes)

My first (in my opinion bad) solution was to start and directly stop advertising in the main loop 

/* Start advertising */
		err = bt_le_adv_start(ADVERTISING_INTERVAL_2, freshAdvertisingPacket, ARRAY_SIZE(freshAdvertisingPacket),		
			      sd, ARRAY_SIZE(sd)); 
		if (err) {
			printk("Advertising failed to start (err %d)\n", err);
			return;
		}

		k_sleep(K_MSEC(40));

		err = bt_le_adv_stop();
		if (err) {
			printk("Advertising failed to stop (err %d)\n", err);
			return;
		}

Is there a way I can trigger this Advertising process? or just send a single packet without starting an Interval?  
Best regards, Jonas Slight smile

  • Hi,

    This is not a common thing to do, so there is no dedicated API for doing this. The simplest is exactly what you described that you don't want to do: Start advertising with a long advertising interval, and stop advertising before the next advertising event. You do not need to do this with a delay (k_sleep()) in your code, though. A more elegant approach could be to use a delayed work queue item, so that you just post the work item to disable advertising sometime in the future.

    Another approach could be to keep advertising regularly, but sync sensor readings to the advertising events by using radio notifications from MPSL.

Related