1

I'm creating a C/C++ library that will send and receive data to a bluetooth device. This library will be used for both iOS and Android. So, prior to the data transmission, I paired the iOS device (iPod) to the bluetooth device. Once the connection is successful, I start sending data from the C++ library. But the problem is, my code is failing when opening the port (open returns -1). Below is my code snippet:

struct termios options;
int tty_fd;

//const char *port = "/dev/rfcomm0";
const char* port = "/dev/tty.F4-VFI-PWM-iRDA-SerialP";

cout << "Trying to open port: " << port << endl;

tty_fd = open(port, (O_RDWR | O_NOCTTY  | O_NONBLOCK)); //O_NDELAY

if (tty_fd < 0)
{
    cout << "Failed to open port: " << port << ", error code: " << tty_fd << endl;
}

Does anyone knows the correct way to communicate to a bluetooth device using C/C++ in iOS?

superm0
  • 963
  • 11
  • 19
  • try to check this answer http://stackoverflow.com/a/28209383/1067147 – WINSergey Dec 24 '15 at 13:37
  • I'm afraid you will not be able to communicate such way on iOS because Apple has intentionally disabled Bluetooth serial profile support on iOS and expects you to use External Accessory Framework for communicating with MFi certified devices (and iPod should be compatible with it, in theory). – JustAMartin Jan 25 '17 at 13:17

0 Answers0