简体   繁体   English

传输端点未连接蓝色

[英]Transport endpoint is not connected bluez

Transport endpoint is not connected 传输端点未连接

#include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/rfcomm.h>

int main(int argc, char **argv)
{
struct sockaddr_rc addr = { 0 };
int s, i, status;
char dest[18] = "88:53:2E:10:BB:B0";
FILE *ptr1;
char c;
char str[1024];
// allocate a socket
s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);

// set the connection parameters (who to connect to)
addr.rc_family = AF_BLUETOOTH;
addr.rc_channel = (uint8_t) 1;
str2ba( dest, &addr.rc_bdaddr );

// connect to server
status = connect(s, (struct sockaddr *)&addr, sizeof(addr));

// send a message
if( status == 0 ) {
ptr1=fopen("//home//aathreya//Desktop//Bluetooth//imudata_acm0.dat","r"); //open file to be read
i=0;
while((c=fgetc(ptr1))!= EOF) //copy 1024 bytes at a time to a string
    {
    str[i]=c;
    i++;
    if (i==1024)
        {
        i=0;
        status = write(s, str, 1024);
        }
    }
status = write(s, str, 1024);
status = write(s, "stop", 4); //flag to stop reading at client
fclose(ptr1);
}

if( status < 0 ) perror("uh oh");

close(s);
return 0;
}

i used this code from http://people.csail.mit.edu/albert/bluez-intro/x502.html . 我从http://people.csail.mit.edu/albert/bluez-intro/x502.html使用了此代码。 i modified it to trnsfer a large file of 8 mb by bluetooth by using file functions of c. 我将其修改为使用c的文件功能通过蓝牙传输8 mb的大文件。 i am getting the error "transport endpoint is not connected" what to do? 我收到错误“传输端点未连接”怎么办?

In the code you have specified channel number as 1 addr.rc_channel = (uint8_t) 1; 在代码中,您已将通道号指定为1 addr.rc_channel =(uint8_t)1; But channel number 1 stands for SDP which cannot be used for file transfer If your remote device mobile or any other device and if it supports OPP then you can specify channel number as 9 addr.rc_channel = (uint8_t) 9; 但是通道号1代表不能用于文件传输的SDP。如果您的远程设备移动设备或任何其他设备并且支持OPP,则可以将通道号指定为9 addr.rc_channel =(uint8_t)9; and you can see file transfer successful. 您会看到文件传输成功。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM