How to use the 2.4G to simulate send Advertising packet with non-connectable and non-scannable with nrf52832

I want to send Advertising packet with non-connectable and non-scannable via 2.4G without using the Bluetooth protocol stack. I try Congfig Nrf52832 's RADIO ,but it didn't work.

unsigned char broadcast_data[] = 
{
	0x02,17,
	0x01,0x02,0x03,0x04,0x05,0x06,//mac
	0x02,0x01,0x05,
	0x07,0x08,'H', 'e', 'l', 'l', 'o','Y',
};

__STATIC_INLINE void nrf_radio_config_as_advertisement(unsigned char ch)
{
	
	// Radio config
    NRF_RADIO->TXPOWER   = (NRF_RADIO_TXPOWER_0dBm << RADIO_TXPOWER_TXPOWER_Pos);
    NRF_RADIO->FREQUENCY = ch == 37 ? 2 : (ch == 38 ? 26 : 80);
    NRF_RADIO->MODE      = (RADIO_MODE_MODE_Ble_1Mbit << RADIO_MODE_MODE_Pos);

#if 1

	NRF_RADIO->PCNF0 =  (RADIO_PCNF0_S0LEN_1BYTE << RADIO_PCNF0_S0LEN_Pos) |
						(RADIO_PCNF0_S1LEN_0bit << RADIO_PCNF0_S1LEN_Pos) |
						(RADIO_PCNF0_LFLEN_8bit << RADIO_PCNF0_LFLEN_Pos) ;
	
	
	NRF_RADIO->PCNF1 =  (RADIO_PCNF1_WHITEEN_Disabled    << RADIO_PCNF1_WHITEEN_Pos) |
						(RADIO_PCNF1_ENDIAN_Little       << RADIO_PCNF1_ENDIAN_Pos)  |
						(3                               << RADIO_PCNF1_BALEN_Pos)   |
						(0                               << RADIO_PCNF1_STATLEN_Pos) |
						(37                              << RADIO_PCNF1_MAXLEN_Pos);  
#else
    
	
	NRF_RADIO->PCNF0 =  (0 << RADIO_PCNF0_S0LEN_Pos) |
						(0 << RADIO_PCNF0_S1LEN_Pos) |
						(0 << RADIO_PCNF0_LFLEN_Pos) ;
	
	
	NRF_RADIO->PCNF1 =  (RADIO_PCNF1_WHITEEN_Disabled    << RADIO_PCNF1_WHITEEN_Pos) |
						(RADIO_PCNF1_ENDIAN_Little       << RADIO_PCNF1_ENDIAN_Pos)  |
						(3                               << RADIO_PCNF1_BALEN_Pos)   |
						(19                              << RADIO_PCNF1_STATLEN_Pos) |
						(19                              << RADIO_PCNF1_MAXLEN_Pos);  
#endif
	
	NRF_RADIO->DATAWHITEIV = ch|0x40;
	NRF_RADIO->PCNF1 |= RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos;
	
	
    NRF_RADIO->BASE0 = 0x8E89BED6;
    NRF_RADIO->PREFIX0 = 0x8E8E8E8E; 
	
	NRF_RADIO->BASE1 = 0x8E89BED6;
    NRF_RADIO->PREFIX1 = 0x8E8E8E8E; 
	
	NRF_RADIO->TXADDRESS   = 0x00UL;
	
	
    NRF_RADIO->CRCCNF =(RADIO_CRCCNF_LEN_Three << RADIO_CRCCNF_LEN_Pos |RADIO_CRCCNF_SKIPADDR_Skip << RADIO_CRCCNF_SKIPADDR_Pos);
    
	NRF_RADIO->CRCINIT = 0x555555UL; 
    NRF_RADIO->CRCPOLY = 0x0100065B; 
	
	
}

Related