Skip to content

Commit fc43142

Browse files
committed
Add area option
1 parent ef0476f commit fc43142

File tree

9 files changed

+98
-20
lines changed

9 files changed

+98
-20
lines changed

dist/webduino-all.js

Lines changed: 76 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,7 +2496,7 @@ Paho.MQTT = (function (global) {
24962496
})(window);
24972497

24982498
var webduino = webduino || {
2499-
version: '0.4.20'
2499+
version: '0.4.22'
25002500
};
25012501

25022502
if (typeof exports !== 'undefined') {
@@ -4816,6 +4816,9 @@ if (typeof exports !== 'undefined') {
48164816
device: options
48174817
};
48184818
}
4819+
if (options.area === 'china') {
4820+
options.server = WebArduino.SERVER_CHINA;
4821+
}
48194822
options = util.extend(getDefaultOptions(options), options);
48204823
options.server = parseServer(options.server);
48214824

@@ -4892,6 +4895,7 @@ if (typeof exports !== 'undefined') {
48924895
};
48934896

48944897
WebArduino.DEFAULT_SERVER = 'wss://ws.webduino.io:443';
4898+
WebArduino.SERVER_CHINA = 'wss://ws.webduino.com.cn';
48954899

48964900
function mockMessageEvent(board, message) {
48974901
board._transport.emit(TransportEvent.MESSAGE, message);
@@ -5492,6 +5496,72 @@ chrome.bluetoothSocket = chrome.bluetoothSocket || (function (_api) {
54925496
scope.board.Smart = Smart;
54935497
}));
54945498

5499+
+(function(factory) {
5500+
if (typeof exports === 'undefined') {
5501+
factory(webduino || {});
5502+
} else {
5503+
module.exports = factory;
5504+
}
5505+
}(function(scope) {
5506+
'use strict';
5507+
5508+
var util = scope.util,
5509+
TransportEvent = scope.TransportEvent,
5510+
Board = scope.Board,
5511+
BoardEvent = scope.BoardEvent,
5512+
proto;
5513+
5514+
function Bit(options) {
5515+
if (typeof options === 'string') {
5516+
options = {
5517+
url: options
5518+
};
5519+
}
5520+
options = util.extend(getDefaultOptions(options), options);
5521+
options.server = parseServer(options.server);
5522+
5523+
Board.call(this, options);
5524+
}
5525+
5526+
function getDefaultOptions(opts) {
5527+
return {
5528+
transport: 'websocket',
5529+
server: Bit.DEFAULT_SERVER,
5530+
login: 'admin',
5531+
password: 'password',
5532+
autoReconnect: false,
5533+
multi: false
5534+
};
5535+
}
5536+
5537+
function parseServer(url) {
5538+
if (url.indexOf('://') === -1) {
5539+
url = (typeof location !== 'undefined' &&
5540+
location.protocol === 'https:' ? 'wss:' : 'ws:') +
5541+
'//' + url;
5542+
}
5543+
url = util.parseURL(url);
5544+
return url.protocol + '//' + url.host + '/';
5545+
}
5546+
5547+
Bit.prototype = proto = Object.create(Board.prototype, {
5548+
constructor: {
5549+
value: Bit
5550+
}
5551+
});
5552+
5553+
proto.startup = function() {
5554+
this._isReady = true;
5555+
this.getPin(34).setMode(2); //set analogNum 6 = pin34
5556+
this.emit(webduino.BoardEvent.READY, this);
5557+
};
5558+
5559+
Bit.DEFAULT_SERVER = 'wss://ws.webduino.io:443';
5560+
5561+
5562+
scope.board.Bit = Bit;
5563+
5564+
}));
54955565
+(function (factory) {
54965566
if (typeof exports === 'undefined') {
54975567
factory(webduino || {});
@@ -8952,14 +9022,14 @@ chrome.bluetoothSocket = chrome.bluetoothSocket || (function (_api) {
89529022

89539023
/**
89549024
* Fires when the RFID entered.
8955-
*
9025+
*
89569026
* @event RFIDEvent.ENTER
89579027
*/
89589028
ENTER: 'enter',
89599029

89609030
/**
89619031
* Fires when the RFID leaved.
8962-
*
9032+
*
89639033
* @event RFIDEvent.LEAVE
89649034
*/
89659035
LEAVE: 'leave'
@@ -8969,7 +9039,7 @@ chrome.bluetoothSocket = chrome.bluetoothSocket || (function (_api) {
89699039
* The RFID class.
89709040
*
89719041
* RFID reader is used to track nearby tags by wirelessly reading a tag's unique ID.
8972-
*
9042+
*
89739043
* @namespace webduino.module
89749044
* @class RFID
89759045
* @constructor
@@ -9000,11 +9070,11 @@ chrome.bluetoothSocket = chrome.bluetoothSocket || (function (_api) {
90009070
}
90019071

90029072
if (msg.length === 1) {
9003-
val = 0;
90049073
_this._leaveHandlers.forEach(function (fn, idx, ary) {
90059074
fn.call(_this, val);
90069075
});
90079076
_this.emit(RFIDEvent.LEAVE, val);
9077+
val = null;
90089078
} else {
90099079
val = String.fromCharCode.apply(null, msg);
90109080
_this._enterHandlers.forEach(function (fn, idx, ary) {
@@ -9021,7 +9091,7 @@ chrome.bluetoothSocket = chrome.bluetoothSocket || (function (_api) {
90219091

90229092
/**
90239093
* The state indicating whether the module is reading.
9024-
*
9094+
*
90259095
* @attribute isReading
90269096
* @type {Boolean} isReading
90279097
* @readOnly

dist/webduino-all.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/webduino-base.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2496,7 +2496,7 @@ Paho.MQTT = (function (global) {
24962496
})(window);
24972497

24982498
var webduino = webduino || {
2499-
version: '0.4.20'
2499+
version: '0.4.22'
25002500
};
25012501

25022502
if (typeof exports !== 'undefined') {
@@ -4816,6 +4816,9 @@ if (typeof exports !== 'undefined') {
48164816
device: options
48174817
};
48184818
}
4819+
if (options.area === 'china') {
4820+
options.server = WebArduino.SERVER_CHINA;
4821+
}
48194822
options = util.extend(getDefaultOptions(options), options);
48204823
options.server = parseServer(options.server);
48214824

@@ -4892,6 +4895,7 @@ if (typeof exports !== 'undefined') {
48924895
};
48934896

48944897
WebArduino.DEFAULT_SERVER = 'wss://ws.webduino.io:443';
4898+
WebArduino.SERVER_CHINA = 'wss://ws.webduino.com.cn';
48954899

48964900
function mockMessageEvent(board, message) {
48974901
board._transport.emit(TransportEvent.MESSAGE, message);

dist/webduino-base.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/files/src_module_RFID.js.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ <h1>src/module/RFID.js <small>File</small></h1>
113113

114114
/**
115115
* Fires when the RFID entered.
116-
*
116+
*
117117
* @event RFIDEvent.ENTER
118118
*/
119119
ENTER: &#x27;enter&#x27;,
120120

121121
/**
122122
* Fires when the RFID leaved.
123-
*
123+
*
124124
* @event RFIDEvent.LEAVE
125125
*/
126126
LEAVE: &#x27;leave&#x27;
@@ -130,7 +130,7 @@ <h1>src/module/RFID.js <small>File</small></h1>
130130
* The RFID class.
131131
*
132132
* RFID reader is used to track nearby tags by wirelessly reading a tag&#x27;s unique ID.
133-
*
133+
*
134134
* @namespace webduino.module
135135
* @class RFID
136136
* @constructor
@@ -161,11 +161,11 @@ <h1>src/module/RFID.js <small>File</small></h1>
161161
}
162162

163163
if (msg.length === 1) {
164-
val = 0;
165164
_this._leaveHandlers.forEach(function (fn, idx, ary) {
166165
fn.call(_this, val);
167166
});
168167
_this.emit(RFIDEvent.LEAVE, val);
168+
val = null;
169169
} else {
170170
val = String.fromCharCode.apply(null, msg);
171171
_this._enterHandlers.forEach(function (fn, idx, ary) {
@@ -182,7 +182,7 @@ <h1>src/module/RFID.js <small>File</small></h1>
182182

183183
/**
184184
* The state indicating whether the module is reading.
185-
*
185+
*
186186
* @attribute isReading
187187
* @type {Boolean} isReading
188188
* @readOnly

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webduino-js",
3-
"version": "0.4.21",
3+
"version": "0.4.22",
44
"main": "index.js",
55
"description": "The Webduino Javascript Core, for Browser and Node.js",
66
"repository": "https://github.com/webduinoio/webduino-js.git",

src/core/WebArduino.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
device: options
1919
};
2020
}
21+
if (options.area === 'china') {
22+
options.server = WebArduino.SERVER_CHINA;
23+
}
2124
options = util.extend(getDefaultOptions(options), options);
2225
options.server = parseServer(options.server);
2326

@@ -94,6 +97,7 @@
9497
};
9598

9699
WebArduino.DEFAULT_SERVER = 'wss://ws.webduino.io:443';
100+
WebArduino.SERVER_CHINA = 'wss://ws.webduino.com.cn';
97101

98102
function mockMessageEvent(board, message) {
99103
board._transport.emit(TransportEvent.MESSAGE, message);

src/webduino.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
var webduino = webduino || {
2-
version: '0.4.21'
2+
version: '0.4.22'
33
};
44

55
if (typeof exports !== 'undefined') {

0 commit comments

Comments
 (0)