Languages

Menu
Sites
Language
Do not use SAP and connect to android with native code

I try to connect Android and Tizen with native not SAP.

 

In android, java,

mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBtserverSocket = null;
mBtSocket = null;
UUID uuid=UUID.fromString("10001101-0000-1000-8000-00805F9B34FB");
mBtserverSocket=mBluetoothAdapter.listenUsingRfcommWithServiceRecord("myapp", uuid);

mBtSocket = mBtserverSocket.accept(); <-block

mInput=mBtSocket.getInputStream();

 

In tizen, c,

res=bt_initialize();

res = bt_socket_set_connection_state_changed_cb(socket_connection_state_changed, NULL);

res = bt_socket_connect_rfcomm("D8:C4:6A:47:0F:B8", "10001101-0000-1000-8000-00805F9B34FB"); <- successfully pass

res = bt_socket_set_data_received_cb(bt_socket_data_clientreceived_cb, NULL);

bt_socket_send_data(client_socket_fd, data, data_len); <- error

 

Phone and gear are connected with gear manager arleady before above process.  I want to do data exchange with bluetooth but not using SAP.

Android server is ready with mBtserverSocket.accept().  Then tizen client call bt_socket_connect_rfcomm() to connect Android server.   bt_socket_connect_rfcomm() don't return error and pass.

1. But when Tizen client call bt_socket_send_data(client_socket_fd, data, data_len), client_socket_fd is 0 and return error, 'Bad file descriptor'.

2. And Android is block state in accept().

3. In socket_connection_state_changed()

if (connection_state == BT_SOCKET_CONNECTED)
    {
        if (connection != NULL)
    {
            // socket_fd is used for sending data and disconnecting a device
            client_socket_fd = connection->socket_fd;

*Also not come here*

 

 

Please advice to me about it.

 

Responses

1 Replies
Mango Bar

did you solve this error ? If problem yet exists,  give your full log file here.

Can you please share, why you are not interested to use SAP  for android and tizen communication ?