Hi

Looked at the archives but hard to see anything on my issues with using the
bluetooth adapter on my android device.

The problem is that the standard socket call for RFCOMM keeps failing with
an error code of "1". Iti is as if the adapter is not initialized. Socket
handle does not return a real handle and is < 1. If I change the socket
call to any normal (non-bluetooth) call it works but can't bind to bt of
course.

{
    struct sockaddr_rc loc_addr = { 0 }, rem_addr = { 0 };
    char buf[1024] = { 0 };
    int s, client, bytes_read;
    socklen_t opt = sizeof(rem_addr);

    // allocate socket

    s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

    // bind socket to port 1 of the first available
    // local bluetooth adapter
    loc_addr.rc_family = AF_BLUETOOTH;
    loc_addr.rc_bdaddr = *BDADDR_ANY;

    loc_addr.rc_channel = (uint8_t) 1;
    bind(s, (struct sockaddr *)&loc_addr, sizeof(loc_addr

*************************

The Java activity based code uses this to initialize the BT device through
the adapter and enables it -

BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if (mBluetoothAdapter == null) {

    // Device does not support Bluetooth
}

if (!mBluetoothAdapter.isEnabled()) {

    Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);

    startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}

How can I do this in native code, since my java wrapper is just a call
into this code base.

thanks,

/mpd

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-kernel

Reply via email to