summaryrefslogtreecommitdiff
path: root/examples/opiebluez/oblueztest/main.cpp
blob: 6c2ca75deb98bf8c973571d73fb3b10453e96e8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <opie2/odebug.h>
#include <opie2/obluetooth.h>

using namespace Opie::Core;
using namespace Opie::Bluez;

int main( int argc, char** argv )
{
    OBluetooth* sys = OBluetooth::instance();
    OBluetooth::InterfaceIterator it = sys->iterator();

    while( it.current() )
    {
        odebug << "APP: Bluetooth host controller interface '" << it.current()->name() << "' has MAC '" << it.current()->macAddress() << "'" << oendl;
        odebug << "APP: Interface is " << ( it.current()->isUp() ? "UP" : "DOWN" ) << "." << oendl;
        //odebug << "APP: Trying to toggle state..." << oendl;
        //it.current()->setUp( !it.current()->isUp() );
        //odebug << "APP: Interface is " << ( it.current()->isUp() ? "UP" : "DOWN" ) << "." << oendl;

        odebug << "APP: scanning..." << oendl;

        OBluetoothInterface::DeviceIterator devit = it.current()->neighbourhood();
        while( devit.current() )
        {
            odebug << "APP: Neighbourhood '" << devit.current()->name() << "' has MAC '" << devit.current()->macAddress() << "'" << oendl;
            odebug << "APP: Neighbourhood '" << devit.current()->name() << "' has class '" << devit.current()->deviceClass() << "'" << oendl;
            ++devit;
        }

        ++it;
    }
    return 0;
}