是否可以使用蓝牙javascript扩展API来实现蓝牙服务器(换句话说,监听套接字),这可以允许设备(蓝牙客户端)连接?
根据目前的文件和极少数的例子,我发现不清楚这是否可能。
感谢。
答案 0 :(得分:2)
是: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
});
});