Skip to content

Commit 7c2b151

Browse files
committed
data segmentation
1 parent 0340dfe commit 7c2b151

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

IrRaw.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
function IrRaw(board, pinMapping) {
2424
Module.call(this);
2525
this._board = board;
26+
this._irInfo = "";
2627
this.pinSendIR = this.pinRecvIR = -1;
2728
// this = this;
2829
if (typeof pinMapping === 'object') {
@@ -40,6 +41,7 @@
4041
self._board.on(webduino.BoardEvent.SYSEX_MESSAGE, function (event) {
4142
var m = event.message;
4243
//send IR data to Board
44+
4345
if (m[0] == 0x04 && m[1] == 0x09 && m[2] == 0x0B) {
4446
log("send IR data to Board callback");
4547
if (lastSendIR) {
@@ -57,13 +59,18 @@
5759
//record IR data
5860
else if (m[0] == 0x04 && m[1] == 0x09 && m[2] == 0x0D) {
5961
log("record IR callback...");
60-
var strInfo = '';
62+
var strData = "";
6163
for (var i = 3; i < m.length; i++) {
62-
strInfo += String.fromCharCode(m[i]);
64+
strData += String.fromCharCode(m[i]);
6365
}
64-
self.irData = strInfo;
65-
self.irRecvCallback(self.irData);
66-
} else {
66+
self._irInfo += strData;
67+
68+
}
69+
else if (m[0] == 0x04 && m[1] == 0x09 && m[2] == 0x0E) {
70+
self.irRecvCallback(self._irInfo);
71+
self._irInfo = "";
72+
}
73+
else {
6774
log(event);
6875
}
6976
});
@@ -106,7 +113,6 @@
106113
});
107114

108115
proto.receive = function (callback) {
109-
console.log("receive:" + this.pinRecvIR);
110116
this.irRecvCallback = callback;
111117
if (this.pinRecvIR > 0) {
112118
// this._board.send([0xF0, 0x04, 0x09, 0x0D, this.pinRecvIR, 0xF7]);
@@ -116,7 +122,6 @@
116122
};
117123

118124
proto.send = function (data, callback) {
119-
console.log("send:" + this.pinSendIR);
120125
if (this.pinSendIR > 0) {
121126
sendIRCmd(data, sendLen, this);
122127
this.irSendCallback = callback;

0 commit comments

Comments
 (0)