Languages

Menu
Sites
Language
socket_connection_state_changed not work in multithread

Hello.

I register callback function like below.

bt_socket_set_connection_state_changed_cb(socket_connection_state_changed, NULL);

Arleady I test my bluetooth functions and work well with single thread data transfer.

But when I start multithread, socket_connection_state_changed don't work as should do.

 

For example, I call bt_socket_connect_rfcomm() in two thread almost simutanously. remote_address is same but uuid is different.

Remote device is accepting two different uuid matched tizen uuid.

socket_connection_state_changed is called twice and work well at one call.  It can receive client_socket and can do data transfer.

But other call show BT_ERROR_NOW_IN_PROGRESS error in parameter result.

What is mean this error and how can I take care multithread works in this situation?

 

I can see BT_ERROR_NOW_IN_PROGRESS error in other tizen API sometimes.  But there are no reference what to do in this case.

 

 

Responses

2 Replies
An

I searched some suspect from last qusertion.

 

Problem : Client device was connecting to Server device only once.

After that error was showing: [socket_connection_state_changed_cb] Failed. result = -29359868

Solution: When, client device was trying to connect the server device second time it failed, because it was already connected. When, I disconnect and again connect, the problem is solved.

 

Then, there are no way to connect to other service(uuid) in connected device arleady?

 

Iqbal Hossain

hi  An

This BT_ERROR_NOW_IN_PROGRESS clearly tells us the server device is busy at second call. Although according to the documentation this return value is unknown to me. 

See this https://developer.tizen.org/ko/development/api-references/native-application?redirect=/dev-guide/2.4/org.tizen.native.mobile.apireference/group__CAPI__NETWORK__BLUETOOTH__SOCKET__MODULE.html#ga196efdd4c1bbb6cf56bd564e489bf258 

Return values:
BT_ERROR_NONE Successful
BT_ERROR_NOT_INITIALIZED Not initialized
BT_ERROR_INVALID_PARAMETER Invalid parameter
BT_ERROR_NOT_SUPPORTED Not supported
I guess these returns are for single call and  your case is about multithread. During your second request it returned that it is already busy with another request. May be multithread is not supported in this case. Your intention is also not clear to me why do you need multithread.