Example #1
0
/**
 * @brief  This function puts the device in connectable mode.
 * @note   If you want to specify a UUID list in the advertising data, those data
 *         can be specified as a parameter in aci_gap_set_discoverable().
 *         For manufacture data, aci_gap_update_adv_data must be called.
 *         Ex.:
 *           tBleStatus ret;
 *           const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'};
 *           const uint8_t serviceUUIDList[] = {AD_TYPE_16_BIT_SERV_UUID, 0x34, 0x12};
 *           const uint8_t manuf_data[] = {4, AD_TYPE_MANUFACTURER_SPECIFIC_DATA, 0x05, 0x02, 0x01};
 *           ret = aci_gap_set_discoverable(ADV_IND, 0, 0, RANDOM_ADDR, NO_WHITE_LIST_USE,
 *                                          8, local_name, 3, serviceUUIDList, 0, 0);
 *           ret = aci_gap_update_adv_data(5, manuf_data);
 */
void set_bluenrg_connectable(void)
{
  tBleStatus ret;
  const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G'};

  /* disable scan response */
  hci_le_set_scan_resp_data(0, NULL);
  /*PRINTF("General Discoverable Mode.\n");*/

  ret = aci_gap_set_discoverable(ADV_IND, 0, 0, RANDOM_ADDR, NO_WHITE_LIST_USE,
                                 8, local_name, 0, NULL, 0, 0);
  if (ret != 0)
    BSP_LED_On(LED4);
}
void setConnectable(void)
{  
    /* Set Name as OTAServiceMgr */
    const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'O','T','A','S','e','r','v','i','c','e','M','g','r'};

#ifdef ST_OTA_BTL
    /* Add OTA service UUID to scan response */
    hci_le_set_scan_resp_data(18,BTLServiceUUID4Scan); 
#endif 
    //PRINTF("General Discoverable Mode.\n");
    
    aci_gap_set_discoverable(ADV_IND, 0, 0, RANDOM_ADDR, NO_WHITE_LIST_USE,
                             14, local_name, 0, NULL, 0, 0);    

    //PRINTF("%d\n",ret);
}
Example #3
0
/**
 * @brief  Make the device connectable
 * @param  None 
 * @retval None
 */
void Make_Connection(void)
{  
  tBleStatus ret;
  
  
  if(BLE_Role == CLIENT) {
    
    PRINTF("Client Create Connection\n");
    tBDAddr bdaddr = {0xaa, 0x00, 0x00, 0xE1, 0x80, 0x02};
    //tBDAddr bdaddr = {0xfd, 0x00, 0x25, 0xec, 0x02, 0x04}; //BT address for HRM test
    
    BSP_LED_On(LED2); //To indicate the start of the connection and discovery phase
    
    // Intial value for connection interval 9
    /*
    Scan_Interval, Scan_Window, Peer_Address_Type, Peer_Address, Own_Address_Type, Conn_Interval_Min, 
    Conn_Interval_Max, Conn_Latency, Supervision_Timeout, Conn_Len_Min, Conn_Len_Max    
    */
    ret = aci_gap_create_connection(SCAN_P, SCAN_L, PUBLIC_ADDR, bdaddr, PUBLIC_ADDR, CONN_P1, CONN_P2, 0, 
      SUPERV_TIMEOUT, CONN_L1 , CONN_L2);

    //ret = aci_gap_create_connection(0x4000, 0x4000, PUBLIC_ADDR, bdaddr, PUBLIC_ADDR, 40, 40, 0, 600, 2000 , 2000);
    
    if (ret != 0){
      PRINTF("Error while starting connection.\n");
      Clock_Wait(100);
    }
    
  } else  {
    
    const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'B','l','u','e','N','R','G','_','C','h','a','t'};
    
    /* disable scan response */
    hci_le_set_scan_resp_data(0,NULL);
    
    PRINTF("General Discoverable Mode ");
    /*
    Advertising_Event_Type, Adv_Interval_Min, Adv_Interval_Max, Address_Type, Adv_Filter_Policy,
    Local_Name_Length, Local_Name, Service_Uuid_Length, Service_Uuid_List, Slave_Conn_Interval_Min,
    Slave_Conn_Interval_Max
    */
    ret = aci_gap_set_discoverable(ADV_IND, 0, 0, PUBLIC_ADDR, NO_WHITE_LIST_USE,
                                   13, local_name, 0, NULL, 0, 0);
    PRINTF("%d\n",ret);
  }
}
/**
	*@brief 	Start To Adv
	*@param  	None
	*@retval 	ret
	*/
tBleStatus ble_device_start_advertising(void)
{
    tBleStatus ret;
    uint8_t uuid_length = 3;
    uint8_t serviceUUIDList[] = {AD_TYPE_16_BIT_SERV_UUID_CMPLT_LIST,0x90,0xFE};

    /* disable scan response */
    hci_le_set_scan_resp_data(0,NULL);
    HAL_Delay(1);
    ret = aci_gatt_update_char_value(service_handle, dev_name_char_handle, 0,
                                     adv_name_len, adv_name);
      if(ret){
         printf("aci_gatt_update_char_value failed.\n");
      }
    /*min_adv_interval > 32*0.625*/
    ret = aci_gap_set_discoverable(ADV_IND, m_adv_params.interval, m_adv_params.interval, PUBLIC_ADDR, NO_WHITE_LIST_USE,
                                  local_name_len, (char*)local_name, uuid_length, serviceUUIDList, 0, 0);//// start advertising
    
    return ret;
}
Example #5
0
/* start advertising */
void ble_device_start_advertising(void)
{
    tBleStatus ret;
    const char local_name[] = {AD_TYPE_COMPLETE_LOCAL_NAME,'J','U','M','A','&','S','T'};////set advertising name
    
    /* disable scan response */
    hci_le_set_scan_resp_data(0,NULL);
    
    PRINTF("General Discoverable Mode ");
    /*
    Advertising_Event_Type, Adv_Interval_Min, Adv_Interval_Max, Address_Type, Adv_Filter_Policy,
    Local_Name_Length, Local_Name, Service_Uuid_Length, Service_Uuid_List, Slave_Conn_Interval_Min,
    Slave_Conn_Interval_Max
    */
		//min_adv_interval > 32*0.625
		 ret = aci_gap_set_discoverable(ADV_IND, m_adv_params.interval, m_adv_params.interval, PUBLIC_ADDR, NO_WHITE_LIST_USE,
                                   sizeof(local_name), local_name, 0, NULL, 0, 0);//// start advertising
    
		PRINTF("%d\n",ret);
  }
Example #6
0
/**
	*@brief 	Start To Adv
	*@param  	None
	*@retval 	ret
	*/
tBleStatus ble_device_start_advertising(void)
{
    tBleStatus ret;
    uint8_t uuid_length = 3;
    const uint8_t serviceUUIDList[] = {AD_TYPE_16_BIT_SERV_UUID,0xFE,0x90};

    /* disable scan response */
    hci_le_set_scan_resp_data(0,NULL);
    ret = aci_gatt_update_char_value(service_handle, dev_name_char_handle, 0,
                                     AdvNameLen, AdvName);

    /*min_adv_interval > 32*0.625*/
    ret = aci_gap_set_discoverable(ADV_IND, m_adv_params.interval, m_adv_params.interval, PUBLIC_ADDR, NO_WHITE_LIST_USE,
                                   AdvNameLen+1, LocalName, uuid_length, serviceUUIDList, 0, 0);//// start advertising


    if(ret) {
        while(1);
    }
    return ret;
}