@@ -2496,7 +2496,7 @@ Paho.MQTT = (function (global) {
24962496} ) ( window ) ;
24972497
24982498var webduino = webduino || {
2499- version : '0.4.20 '
2499+ version : '0.4.22 '
25002500} ;
25012501
25022502if ( 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
0 commit comments