Skip to content

Commit d17b035

Browse files
committed
Integrated Chrome bluetooth module.
1 parent 9662ce3 commit d17b035

File tree

17 files changed

+54
-1041
lines changed

17 files changed

+54
-1041
lines changed

src/frameworks/internal/sphero/sphero.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,13 @@ cwc.framework.Sphero = function() {
4040
/** @private {!cwc.framework.Messenger} */
4141
this.messenger_ = new cwc.framework.Messenger()
4242
.setListenerScope(this)
43-
.addListener('__EVENT__COLLISION', this.handleCollision_);
43+
.addListener('__EVENT__COLLISION', this.handleCollision_)
44+
.addListener('__EVENT__changed_values', function(e) {
45+
console.log('Changed values event', e);
46+
})
47+
.addListener('__EVENT__changed_speed', function(e) {
48+
console.log('Changed speed event', e);
49+
});
4450
};
4551

4652

src/mode/lego/ev3/connection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ cwc.mode.lego.ev3.Connection.prototype.init = function() {
109109
* Connects the EV3 unit.
110110
*/
111111
cwc.mode.lego.ev3.Connection.prototype.connect = function() {
112+
let bluetoothInstance = this.helper.getInstance('bluetooth');
113+
if (!bluetoothInstance) {
114+
return;
115+
}
112116
if (!this.isConnected()) {
113-
let bluetoothInstance = this.helper.getInstance('bluetooth', true);
114117
bluetoothInstance.autoConnectDevice(this.autoConnectName,
115118
this.api_.connect.bind(this.api_));
116119
}

src/mode/makeblock/mbot/connection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ cwc.mode.makeblock.mbot.Connection.prototype.init = function() {
8989
* @export
9090
*/
9191
cwc.mode.makeblock.mbot.Connection.prototype.connect = function(opt_event) {
92+
let bluetoothInstance = this.helper.getInstance('bluetooth');
93+
if (!bluetoothInstance) {
94+
return;
95+
}
9296
if (!this.isConnected()) {
93-
let bluetoothInstance = this.helper.getInstance('bluetooth', true);
9497
bluetoothInstance.autoConnectDevice(this.autoConnectName, function(device) {
9598
if (device) {
9699
this.api_.connect(device);

src/mode/makeblock/mbot_ranger/connection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,11 @@ cwc.mode.makeblock.mbotRanger.Connection.prototype.init = function() {
9090
*/
9191
cwc.mode.makeblock.mbotRanger.Connection.prototype.connect = function(
9292
opt_event) {
93+
let bluetoothInstance = this.helper.getInstance('bluetooth');
94+
if (!bluetoothInstance) {
95+
return;
96+
}
9397
if (!this.isConnected()) {
94-
let bluetoothInstance = this.helper.getInstance('bluetooth', true);
9598
bluetoothInstance.autoConnectDevice(this.autoConnectName, function(device) {
9699
if (device) {
97100
this.api_.connect(device);

src/mode/sphero/classic/connection.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ cwc.mode.sphero.classic.Connection.prototype.init = function() {
104104
* @export
105105
*/
106106
cwc.mode.sphero.classic.Connection.prototype.connect = function(opt_event) {
107+
let bluetoothInstance = this.helper.getInstance('bluetooth');
108+
if (!bluetoothInstance) {
109+
return;
110+
}
107111
if (!this.isConnected()) {
108-
let bluetoothInstance = this.helper.getInstance('bluetooth', true);
109112
bluetoothInstance.autoConnectDevice(this.autoConnectName,
110113
this.api_.connect.bind(this.api_));
111114
}

src/protocol/low-level/bluetooth/classic/api.js

Lines changed: 0 additions & 180 deletions
This file was deleted.

0 commit comments

Comments
 (0)