Ejemplo n.º 1
0
CAResult_t CAEDRStopDeviceDiscovery(void)
{
    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "IN");

    bool isDiscoveryStarted = false;
    bt_error_e err = bt_adapter_is_discovering(&isDiscoveryStarted);
    // Check the device discovery state
    if (BT_ERROR_NONE != err)
    {
        OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed to get discovery state!, error num [%x]",
                  err);
        return CA_STATUS_FAILED;
    }

    //stop the device discovery process
    if (true == isDiscoveryStarted)
    {
        OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "Stopping the device search process");
        if (BT_ERROR_NONE != (err = bt_adapter_stop_device_discovery()))
        {
            OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Failed to stop discovery!, error num [%x]",
                      err);
        }
    }

    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
    return CA_STATUS_OK;
}
Ejemplo n.º 2
0
// Called by bt_adapter_start_device_discovery / bt_adapter_stop_device_discovery function.
void CProximity::CB_discover_state_change(int result,
        bt_adapter_device_discovery_state_e discovery_state, \
        bt_adapter_device_discovery_info_s *discovery_info, void *user_data)
{
    DBG("callback called.");
#if __INTERNAL_DEBUG_
    DBG("result = %d", result);
#endif

    CbleDevice *pdevice = (CbleDevice *)user_data;

    if ( discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FOUND )
    {
        if ( discovery_info == NULL)
            goto BT_ERROR;
#if __INTERNAL_DEBUG_
        printf("=========== Get RSSI =============\n");
        printf("= address  \t : %s \n", discovery_info->remote_address);
        printf("= name     \t : %s \n", discovery_info->remote_name);
        printf("= rssi     \t : %d \n", (discovery_info->rssi - 65535) );
        printf("===========================================\n");
#endif
        find_referenceThing( discovery_info , pdevice );

        if ( num_set_rssi == pdevice->size()  )
        {
#if __INTERNAL_DEBUG_
            DBG("Stop searching device.");
#endif
            BT_ERROR_CHECK( bt_adapter_stop_device_discovery() );
        }
    }
    else if ( discovery_state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED )
    {
        DBG("state == BT_ADAPTER_DEVICE_DISCOVERY_FINISHED");

        num_set_rssi = 0;
        if ( get_rssi_cnt == RSSI_EA )
        {
            get_rssi_cnt = 0;
            loop_flag = JOB_GET_PROX;
        }
        else
            loop_flag = JOB_GET_RSSI;
    }

    return ;

BT_ERROR:
    return ;
}