Non connectable ADV mode

Hi,

I am trying to change my ADV mode to non connectable.
According to https://www.onsemi.com/forum/t/how-to-set-unconectable-advertisement/1411
I need to:

Advertising mode needs to be set to Broadcaster.

Where do I find this requirement? The documentation states, that the Broadcaster mode is supported only with non-connectable, but not that the non-connectable ADV mode is supported only with broadcaster mode (page 59 in RW-BLE-GP-IS_2mbps.pdf).

Nevertheless I tried it like suggested:
GAPM_DEFAULT_ADV_NONCONN_INTV_MIN/MAX = 160

void vAppSetAdvScanData(bool connectable)
{
    uint8_t companyID[] = APP_COMPANY_ID;
    uint8_t devName[]   = APP_DEVICE_NAME;

    if(connectable){
    	advertiseCmd.op.code = GAPM_ADV_UNDIRECT;
    	advertiseCmd.intv_max = GAPM_DEFAULT_ADV_INTV_MIN;
    	advertiseCmd.intv_max = GAPM_DEFAULT_ADV_INTV_MAX;
    	advertiseCmd.info.host.mode = GAP_GEN_DISCOVERABLE;

    } else {
    	advertiseCmd.op.code = GAPM_ADV_NON_CONN;
    	advertiseCmd.intv_max = GAPM_DEFAULT_ADV_NONCONN_INTV_MIN;
    	advertiseCmd.intv_max = GAPM_DEFAULT_ADV_NONCONN_INTV_MAX;
    	advertiseCmd.info.host.mode = GAP_BROADCASTER_MODE;
    }

    /* Set advertising data as device name + company ID */
    advertiseCmd.info.host.adv_data_len = 0;
    GAPM_AddAdvData(GAP_AD_TYPE_COMPLETE_NAME, devName,
                    APP_DEVICE_NAME_LEN, advertiseCmd.info.host.adv_data,
                    &advertiseCmd.info.host.adv_data_len);
    GAPM_AddAdvData(GAP_AD_TYPE_MANU_SPECIFIC_DATA, companyID,
                    APP_COMPANY_ID_LEN, advertiseCmd.info.host.adv_data,
                    &advertiseCmd.info.host.adv_data_len);

    /* Set scan response data as company ID */
    advertiseCmd.info.host.scan_rsp_data_len = 0;
    if(connectable){
    	GAPM_AddAdvData(GAP_AD_TYPE_MANU_SPECIFIC_DATA, companyID,
    	                    APP_COMPANY_ID_LEN, advertiseCmd.info.host.scan_rsp_data,
    	                    &advertiseCmd.info.host.scan_rsp_data_len);
    }
}

It still does not work. Am I missing something?
Start connectable ADV β†’ GAPM_CancelCmd(); β†’ GAPM_ResetCmd(); -->vAppSetAdvScanData(false);–>GAPM_StartAdvertiseCmd(&advertiseCmd);

My device is not advertising at all after I tried to switch to non connectable.

My goal is to change the ADV mode from connectable to non-connectable after some time. What is the procedure for that?

Thank you for your help.

@stzi

The root cause is that you don’t need to use GAPM_ResetCmd() after using GAPM_CancelCmd() .

  1. First make sure that connectable advertising/ non-connectable advertising alone can work.
    For example:
    Advertising_Start(); is connectable advertising;
    Advertising_Start_nonconnectable(); is non-connectable advertising;

  2. The procedure:
    Start connectable ADV β†’ timer delay – > GAPM_CancelCmd();
    – Wait for complete of GAPM_CancelCmd().
    finished β†’ Start non-connectable ADV

Here is an example for your reference (based on peripheral_server example)
In the GAPM_CmpEvt(), we add this.

case GAPM_ADV_UNDIRECT:         // switch connectable adv  --->  non-connectable adv
	{
		/* If advertisement is cancelled */
		if (param->status == GAP_ERR_CANCELED)
		{
			ble_env[0].state = APPM_READY;
			Advertising_Start_nonconnectable();
		}
	}
	Break;
	
case  GAPM_ADV_NON_CONN:                  // switch non-connectable adv --- >  connectable adv
{
       /* If advertisement is cancelled */
	if (param->status == GAP_ERR_CANCELED){
		ble_env[0].state = APPM_READY;
		Advertising_Start();
     }
 }

@martin.bela

Thank you very much for your reponse. I will try it and report back with my findings.

Regards

1 Like