【问题标题】:Connect laptop and android via bluetooth(labview)通过蓝牙(labview)连接笔记本电脑和安卓
【发布时间】:2014-06-23 02:25:29
【问题描述】:

我想通过蓝牙将笔记本电脑与安卓连接。

我想要做的是将数值从 android 应用程序发送到笔记本电脑上安装的 Labview 程序。

android 程序返回的值会根据按钮单击而变化(例如,当我按下向上按钮时,值 +1)。

我想通过蓝牙将此值发送到笔记本电脑。

找了google、stackoverflow等很多社区,都没有找到任何提示或解决办法。

我使用“blueterm”应用程序(它使安卓能够连接蓝牙设备)连接笔记本电脑和安卓,但笔记本电脑拒绝传入连接!

需要接收数据的程序是LabView。

package com.u2ring.control;

import com.u2ring.control.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.webkit.*;


public class MainActivity extends Activity implements OnClickListener
{
Button Plus, Minus;
TextView Value;
TextView url;
int score = 0;


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Plus = (Button) findViewById(R.id.up);
Minus = (Button) findViewById(R.id.down);

Value = (TextView) findViewById(R.id.number);

String host = getString(R.string.host);

Plus.setOnClickListener(this);
Minus.setOnClickListener(this);
Button bt1 = (Button) findViewById(R.id.button2);
bt1.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View v){
        Intent in = new Intent(MainActivity.this,Secondpage.class);
        startActivity(in);
        }
});};




public void onClick(View v)
{
boolean showText = false;

int id = v.getId();
if (id == R.id.up) {
    score++;
    showText = true;
} else if (id == R.id.down) {
    score--;
    showText = true;
} else if (id == R.id.number) {
    showText = true;
}
if(showText)
Value.setText(String.valueOf(score));

WebView wv= (WebView) findViewById(R.id.web);
wv.loadUrl("http://10.16.27.184:8080/admin/speed/"+Integer.toString(score));
}
}

【问题讨论】:

  • 这里你只是想打开一个网页,你的蓝牙代码在哪里?
  • 我正在显示我的代码...我在这里问是因为我不知道如何连接蓝牙

标签: android bluetooth labview


【解决方案1】:

我希望我早点找到这个话题。很久以前我有同样的问题。并且无法直接使用蓝牙将手机与笔记本电脑连接。 只有一种发送文件的方法,而手机被视为一个容器(基本上是文件夹)。

解决方案非常简单。只需在LabVIEW中实现VI,它将通过内置蓝牙组件传递数据(它必须是为桌面应用程序(Windows)构建的VI,因为默认情况下不支持硬件蓝牙)。

通过这个简单的技巧,您将能够使用蓝牙接收数据。

另外,考虑一下 TCP IP 协议,它会更好地工作:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-30
    • 2016-09-26
    • 2014-05-11
    • 2014-08-31
    相关资源
    最近更新 更多