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


    bool isDiscoveryStarted = false;

    // Check the device discovery state
    bt_error_e err = bt_adapter_is_discovering(&isDiscoveryStarted);
    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;
    }

    //Start device discovery if its not started
    if (false == isDiscoveryStarted)
    {
        err = bt_adapter_start_device_discovery();
        if (BT_ERROR_NONE != err)
        {
            OIC_LOG_V(ERROR, EDR_ADAPTER_TAG, "Device discovery failed!, error num [%x]",
                      err);
            return CA_STATUS_FAILED;
        }
    }

    OIC_LOG(DEBUG, EDR_ADAPTER_TAG, "OUT");
    return CA_STATUS_OK;
}
Ejemplo n.º 2
0
bool CProximity::GetRSSI(CbleDevice *pdevice)
{
#if __INTERNAL_DEBUG_
    DBG("Enter");
#endif
    if ( num_set_rssi == 0 && get_rssi_cnt == 0)
        map_rssi.clear();

    num_set_rssi = 0;
    get_rssi_cnt++;

    for ( int i = 0; i < pdevice->size(); i++ )
        pdevice->setRSSI( (pdevice->getNext(i))->remote_address, 0);

    BT_ERROR_CHECK( bt_adapter_set_device_discovery_state_changed_cb(
                        CProximity::CB_discover_state_change, pdevice) );

    BT_ERROR_CHECK( bt_adapter_start_device_discovery() );

    return true;

BT_ERROR:
    return false;
}