I am trying to connect my target to mobile device through blue-tooth SPP profile. Once bluetooth connection is up, request is made to create rfcomm channel to communicate.
output of
ls -all /dev/rfcomm0
crw-rw-rw- 1 root dialout 216, 0 Jan 1 00:02 /dev/rfcomm0
once rfcomm device is created, in my code I am opening the file and writing data to it.
fd = open('/dev/rfcomm0', O_RDWR | O_NOCTTY | O_SYNC);
write(write(fd, &sendBuffer[0], sendBuffer.size())
write is successful. again if I try to read the data through rfcomm, code does not proceed.
read(fd, recvbuf, recvbuflen)
Since read was not working I tried closing the file descriptor and again open it.
This time it is not able to open /dev/rfcomm0. It returns -1.
Please guide where I am lacking.
Also I am newbie to this, so if there are any documents on bluetooth SPP using C++.