/*----------------------------------------------------------------------------* * NAME * GattStartAdverts * * DESCRIPTION * This function is used to start undirected advertisements and moves to * ADVERTISING state. * * RETURNS * Nothing. * *---------------------------------------------------------------------------*/ extern void GattStartAdverts(bool fast_connection) { /* Variable 'connect_flags' needs to be updated to have peer address type * if Directed advertisements are supported as peer address type will * only be used in that case. We don't support directed advertisements for * this application. */ #ifdef USE_STATIC_RANDOM_ADDRESS uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM; #else uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_PUBLIC; #endif /* USE_STATIC_RANDOM_ADDRESS */ /* Set UCID to INVALID_UCID */ g_lightapp_data.gatt_data.st_ucid = GATT_INVALID_UCID; /* Set advertisement parameters */ gattSetAdvertParams(fast_connection); /* Start GATT connection in Slave role */ GattConnectReq(NULL, connect_flags); }
extern void GattStartAdverts(bool fast_connection) { /* Variable 'connect_flags' needs to be updated to have peer address type * if Directed advertisements are supported as peer address type will * only be used in that case. We don't support directed advertisements for * this application. */ #ifdef USE_STATIC_RANDOM_ADDRESS uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM; #else uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_PUBLIC; #endif /* USE_STATIC_RANDOM_ADDRESS */ /* Set UCID to INVALID_UCID */ g_hr_data.st_ucid = GATT_INVALID_UCID; /* Set advertisement parameters */ gattSetAdvertParams(fast_connection); /* If white list is enabled, set the controller's advertising filter policy * to "process scan and connection requests only from devices in the White * List" */ if((g_hr_data.enable_white_list == TRUE) && (!GattIsAddressResolvableRandom(&(g_hr_data.bonded_bd_addr)))) { #ifdef USE_STATIC_RANDOM_ADDRESS connect_flags = L2CAP_CONNECTION_SLAVE_WHITELIST | L2CAP_OWN_ADDR_TYPE_RANDOM; #else connect_flags = L2CAP_CONNECTION_SLAVE_WHITELIST | L2CAP_OWN_ADDR_TYPE_PUBLIC; #endif /* USE_STATIC_RANDOM_ADDRESS */ } /* Start GATT connection in Slave role */ GattConnectReq(NULL, connect_flags); /* Start advertisement timer */ if(g_hr_data.advert_timer_value) { TimerDelete(g_hr_data.app_tid); /* Start advertisement timer */ g_hr_data.app_tid = TimerCreate(g_hr_data.advert_timer_value, TRUE, gattAdvertTimerHandler); } }
/*----------------------------------------------------------------------------* * NAME * GattStartAdverts * * DESCRIPTION * This function is used to start undirected advertisements and moves to * ADVERTISING state. * * PARAMETERS * p_addr [in] Bonded host address * fast_connection [in] TRUE: Fast advertisements * FALSE: Slow advertisements * * RETURNS * Nothing *----------------------------------------------------------------------------*/ extern void GattStartAdverts(TYPED_BD_ADDR_T *p_addr, bool fast_connection) { /* Variable 'connect_flags' needs to be updated to have peer address type * if Directed advertisements are supported as peer address type will * only be used in that case. We don't support directed advertisements for * this application. */ #ifdef USE_STATIC_RANDOM_ADDRESS uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM; #else uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_PUBLIC; #endif /* USE_STATIC_RANDOM_ADDRESS */ /* Set advertisement parameters */ gattSetAdvertParams(p_addr, fast_connection); /* If white list is enabled, set the controller's advertising filter policy * to "process scan and connection requests only from devices in the White * List" */ if(IsWhiteListEnabled() && !GattIsAddressResolvableRandom(p_addr)) { #ifdef USE_STATIC_RANDOM_ADDRESS connect_flags = L2CAP_CONNECTION_SLAVE_WHITELIST | L2CAP_OWN_ADDR_TYPE_RANDOM; #else connect_flags = L2CAP_CONNECTION_SLAVE_WHITELIST | L2CAP_OWN_ADDR_TYPE_PUBLIC; #endif /* USE_STATIC_RANDOM_ADDRESS */ } /* Start GATT connection in Slave role */ GattConnectReq(NULL, connect_flags); /* Start advertisement timer */ if(g_gatt_data.advert_timer_value) { StartAdvertTimer(g_gatt_data.advert_timer_value); } }
extern void GattStartAdverts(bool fast_connection, gap_mode_connect connect_mode) { uint16 connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_PUBLIC; /* Set UCID to INVALID_UCID */ g_btcar_data.st_ucid = GATT_INVALID_UCID; /* Set advertisement parameters */ gattSetAdvertParams(fast_connection, connect_mode); if(g_btcar_data.bonded && !IsAddressResolvableRandom(&g_btcar_data.bonded_bd_addr) && !IsAddressNonResolvableRandom(&g_btcar_data.bonded_bd_addr)) { if(connect_mode == gap_mode_connect_directed) { connect_flags = L2CAP_CONNECTION_SLAVE_DIRECTED | L2CAP_OWN_ADDR_TYPE_PUBLIC | L2CAP_PEER_ADDR_TYPE_PUBLIC; } else { /* When the device is bonded, set the advertising filter policy to * "process scan and connection requests only from devices in white * list" */ connect_flags = L2CAP_CONNECTION_SLAVE_WHITELIST | L2CAP_OWN_ADDR_TYPE_PUBLIC; } } #ifdef __GAP_PRIVACY_SUPPORT__ /*Check if privacy enabled */ if(IsGapPeripheralPrivacyEnabled()) { if(connect_mode == gap_mode_connect_directed) { /* Set advAddress to reconnection address. */ GapSetRandomAddress(GapGetReconnectionAddress()); connect_flags = L2CAP_CONNECTION_SLAVE_DIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM | L2CAP_PEER_ADDR_TYPE_RANDOM; } else { /* Generate Resolvable random address and use it as advAddress. */ SMPrivacyRegenerateAddress(NULL); if(g_btcar_data.bonded_bd_addr.type == L2CA_RANDOM_ADDR_TYPE) { /* Change to random address */ connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM | L2CAP_PEER_ADDR_TYPE_RANDOM; } else { /* Change to random address */ connect_flags = L2CAP_CONNECTION_SLAVE_UNDIRECTED | L2CAP_OWN_ADDR_TYPE_RANDOM | L2CAP_PEER_ADDR_TYPE_PUBLIC; } } } #endif /* __GAP_PRIVACY_SUPPORT__ */ /* Start GATT connection in Slave role */ GattConnectReq(NULL, connect_flags); /* Start advertisement timer */ if(g_btcar_data.advert_timer_value) { TimerDelete(g_btcar_data.app_tid); /* Start advertisement timer */ g_btcar_data.app_tid = TimerCreate(g_btcar_data.advert_timer_value, TRUE, gattAdvertTimerHandler); } }