MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / connect

Method connect

src/utils/bluetooth/socket_bluetooth_linux.cpp:30–56  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28}
29
30int SocketBluetooth::connect ()
31{
32 if (pipe (rep) == -1)
33 {
34 return (int)SocketBluetoothReturnCodes::OS_SPECIFIC_ERROR;
35 }
36 int flags = fcntl (rep[0], F_GETFL, 0);
37 fcntl (rep[0], F_SETFL, flags | O_NONBLOCK);
38 struct sockaddr_rc addr;
39 memset (&addr, 0, sizeof (addr));
40
41 socket_bt = socket (AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
42 addr.rc_family = AF_BLUETOOTH;
43 addr.rc_channel = (uint8_t)port;
44 str2ba (mac_addr.c_str (), &addr.rc_bdaddr);
45
46 int status = ::connect (socket_bt, (struct sockaddr *)&addr, sizeof (addr));
47 if (status != 0)
48 {
49 return (int)SocketBluetoothReturnCodes::CONNECT_ERROR;
50 }
51
52 int sock_flags = fcntl (socket_bt, F_GETFL, 0);
53 fcntl (socket_bt, F_SETFL, sock_flags | O_NONBLOCK);
54
55 return (int)SocketBluetoothReturnCodes::STATUS_OK;
56}
57
58int SocketBluetooth::send (const char *data, int size)
59{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected