Do I need to setup my android app's bluetooth connection as a server or client?

StackOverflow https://stackoverflow.com/questions/23070254

  •  03-07-2023
  •  | 
  •  

質問

I want to control an embedded system with a simple mechanism: app sends command, embedded system sends data back via a bluetooth module rn-41.

I'm referring to this Android Developer: Tutorial and was wondering whether I need to connect via app as a server or client or whether it doesn't matter.

役に立ちましたか?

解決

Bluetooth has a Master-Slave Architecture. A master can be simultaneously connected to as much as 7 active slaves. If your android app need to control more than one embedded system then you need to configure your android device as a master. If your app need to control only one device you can configure your app either as master or as Slave.

In android terms you can initiate connection to your embedded device as a client using "BluetoothSocket" and get the socket using the function "createRfcommSocketToServiceRecord"

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top