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