Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Troubles to send data from an android phone to another #27

Open
Brileantag opened this issue Sep 2, 2014 · 11 comments
Open

Troubles to send data from an android phone to another #27

Brileantag opened this issue Sep 2, 2014 · 11 comments

Comments

@Brileantag
Copy link

Hi!
I am facing with a problem when i try to send strings from an Android phone to another one (Sender: android 4.2, receiver: android 4.1). The functions discover, connect, pair, enable, startConnectionManager work fine. The write one also seems to work good, because the Success callback is called after have written. After that, the device on which the writter is connected is never notified by any data received.
Here are more details:

  • The devices are paired
  • The devices are connected
  • The connection manager is started on the two devices.
  • The write function ens by calling the success callback

I have seen on Stackoverflow that the problem was caused by the fact that i start the connection manager on both devices. Does this still in instance? i have tried to implement the solution given in that post unsuccessfully. Please, how could i turn round this problem?

@tanelih
Copy link
Owner

tanelih commented Sep 3, 2014

Hi,

The plugin does not actually have any way to accept incoming connections, so even though your receiving device is connected to the device that is writing, they are not communicating through a "shared" socket.

As you can see on StackOverflow, you would need to implement an AcceptThread that would poll for incoming connections in order to receive a socket that both of the devices would know of and could communicate through.

@Brileantag
Copy link
Author

Hi,
i have tried to writte a java Thread to listen to incoming connections. i faced with a new problem, that is how to get the reference to the BluetoothSocket object on which the incoming connection has been made. I have seen in the plugin code that the reference of the _socket is obtained when attempting to connect. Do you know if there is a way to get this reference for the device receiving an incoming connection attempt?

@Brileantag
Copy link
Author

Hi,
Thank you @tanelih , i finally found how to modify the plugin after have read the android bluetooth chat source code.
I have added the AcceptThread, and all is ok.

@arielgpe
Copy link

hey @Brileantag do you have some code to share? im having the same problem but i dont know where to start. Thanks in advance.

@Brileantag
Copy link
Author

Hey @arielgpe , sorry for the late reply. I was not able to use internet for a long period. If still needed, I have a code i could share with you, a small change of the plugin source code. Do you want to have it by mail or should i paste it here?

@arielgpe
Copy link

arielgpe commented Dec 1, 2014

@Brileantag how it is more comfortable to you? im okay with mails or repos that i can fork.

@coderextreme
Copy link

@Brileantag could you paste the code here or email me? Thanks

@coderextreme
Copy link

Would this code work to connect android 4.4.2 to windows 8.1 pc or yosemite mac os x? I haven't looked at what I have to do on desktop yet.

@tanelih
Copy link
Owner

tanelih commented Jan 13, 2015

@coderextreme Hi, the plugin should probably be able to connect to various devices with bluetooth capabilities, such as a desktop pc. You would have to handle the incoming connection on the desktop then.

@hnthakkar
Copy link

Hi @tanelih, even I am facing the same problem
*The devices are paired
*The devices are connected
*The connection manager is started on the two devices.
*The write function ends by calling the success callback
but not able to send data, as @Brileantag mentioned I did try implementing the AcceptThread, but was unsuccessful, and need little more Idea on this.
Can anyone please guide me on this. Thanks.

@tanelih
Copy link
Owner

tanelih commented Apr 10, 2015

@hnthakkar,
This plugin works as a client of sorts, so it needs a server to connect to. The problem with the situation you are describing is that this plugin does not implement a server.

Take a look at this for some guidance on how to implement an AcceptThread, or a server in a sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants