python数据如何用蓝牙发送_通过蓝牙从Android(客户端)向Python(服务器)发送数据...

我正在尝试使用pythonbluez通过蓝牙从Android客户端(nexus4)向Python服务器(Linux机器)发送数据。每当客户端向OutputStream写入一些字节时,它就会抛出一个IO异常“断管”。服务器似乎也不接受任何连接,尽管Android客户端在“socket”之后没有抛出任何异常_名称.连接()”

Android客户端:public class MainActivity extends Activity {

private BluetoothSocket ClientSocket;

private BluetoothDevice Client;

private ConnectedThread Writer;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.main, menu);

return true;

}

public BluetoothAdapter mblue;

public void connect(View sender)

{

mblue = BluetoothAdapter.getDefaultAdapter();

int REQUEST_ENABLE_BT = 1;

final TextView er = (TextView)findViewById(R.id.Error);

if(mblue == null)

er.setText("No Bluetooth!");

else if (mblue.isEnabled()) {

er.setText(mblue.getAddress() + " " + mblue.getName());

}

else{

Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);

startActivityForResult(en

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值