【问题标题】:Can the bluetooth API in chrome be used as a server?chrome中的蓝牙API可以用作服务器吗?
【发布时间】:2013-07-12 13:06:05
【问题描述】:

是否可以使用蓝牙 javascript 扩展 API 来实现蓝牙服务器(换句话说,监听套接字),它可以允许设备(蓝牙客户端)连接?

根据当前的文档和极少数示例,我发现这是否可能是一种不确定性。

谢谢。

【问题讨论】:

    标签: google-chrome bluetooth google-chrome-app chromium


    【解决方案1】:

    是的:https://developer.chrome.com/apps/app_bluetooth#listening

    var uuid = '1105';
    chrome.bluetoothSocket.create(function(createInfo) {
        chrome.bluetoothSocket.onAccept.addListener(function(acceptInfo) {
            if (info.socketId != createInfo.socketId) return;
    
            // Say hello...
            chrome.bluetoothSocket.send(acceptInfo.clientSocketId,
                data, onSendCallback);
    
            // Accepted sockets are initially paused,
            // set the onReceive listener first.
            chrome.bluetoothSocket.onReceive.addListener(onReceive);
            chrome.bluetoothSocket.setPaused(acceptInfo.clientSocketId, false);
        });
    
        chrome.bluetoothSocket.listenUsingRfcomm(
            createInfo.socketId, uuid, function() {
                // check chrome.runtime.lastError
            });
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-21
      • 1970-01-01
      • 2016-07-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多