This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Changing Advertising periodically

Hello,

I need to change my advertising Message periodically. In detail message (A) is sent in every 100ms and message (B) ist sent every 3000ms.

I defined 2 timer:

static void advertising_100ms_handler(void * p_context) {

uint32_t      err_code;
uint8_t laenge = 0;
uint8_t i;

uint8_t m_addl_adv_manuf_data[15];	
m_addl_adv_manuf_data[0] = 0x11; 
m_addl_adv_manuf_data[1] = 0x07; 
m_addl_adv_manuf_data[2] = 0x00; 
m_addl_adv_manuf_data[3] = 0x00; 

for(i = 0; i <= 18; i++)				 
	m_addl_adv_manuf_data[i+4] = 0;

laenge = 0x12;

err_code = sd_ble_gap_adv_data_set(m_addl_adv_manuf_data, laenge, NULL, 0);
APP_ERROR_CHECK(err_code);

nrf_gpio_pin_set(1);
nrf_gpio_pin_clear(1);

}

static void advertising_3000ms_handler(void * p_context) {

uint32_t      err_code;
uint8_t laenge = 0;
uint8_t i;
uint8_t m_addl_adv_manuf_data[15];	
m_addl_adv_manuf_data[0] = 0x11; //Laenge ohne [0] Laengenbyte
m_addl_adv_manuf_data[1] = 0x07; //flag
m_addl_adv_manuf_data[2] = 0xff; //company identifier 
m_addl_adv_manuf_data[3] = 0xff; //company identifier

for(i = 0; i <= 18; i++)				 //16 Byte Payload	
	m_addl_adv_manuf_data[i+4] = 0xff;

laenge = 0x12;

err_code = sd_ble_gap_adv_data_set(m_addl_adv_manuf_data, laenge, NULL, 0);
APP_ERROR_CHECK(err_code);

nrf_gpio_pin_set(2);
nrf_gpio_pin_clear(2);

}

Both timers funktions are exectued right. But the advertising message isn´t changing, message a is sent. But message b isn´t visualized in my sniffer. This isn´t very astonishing because my app is running into HARD FAULT. I canßt tell where my code is corrupting. Is anybody able to see my mistake or can provide a better solution?

Parents
  • This is my timer init:

    	app_timer_create(&advertising_100ms, APP_TIMER_MODE_REPEATED, advertising_100ms_handler);
    	app_timer_start(advertising_100ms, MEASURE_INTERVAL_100, NULL);
    
    	app_timer_create(&advertising_3000ms, APP_TIMER_MODE_REPEATED, advertising_3000ms_handler);
    	app_timer_start(advertising_3000ms, MEASURE_INTERVAL_3000, NULL);    
    

    The first change of my advertising Data works. The first message is created in main.c before power_mange(); is started. The second message is the message generated every 100 ms. But the nthird message won´t come .

    image description

Reply
  • This is my timer init:

    	app_timer_create(&advertising_100ms, APP_TIMER_MODE_REPEATED, advertising_100ms_handler);
    	app_timer_start(advertising_100ms, MEASURE_INTERVAL_100, NULL);
    
    	app_timer_create(&advertising_3000ms, APP_TIMER_MODE_REPEATED, advertising_3000ms_handler);
    	app_timer_start(advertising_3000ms, MEASURE_INTERVAL_3000, NULL);    
    

    The first change of my advertising Data works. The first message is created in main.c before power_mange(); is started. The second message is the message generated every 100 ms. But the nthird message won´t come .

    image description

Children
No Data
Related