Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
1) Now also clears joins when processor is about to send update request
2) No longer cancel update request timer on IPID error
3) No longer clears join on socket disconnect
4) Reformulated response for 0x0F 0X02 processor response.  This is now treated as an IP ID registry request, as opposed to just a warning.  This hopefully will help people having difficulty with reconnects.
  • Loading branch information
scottshanafelt committed Aug 10, 2011
1 parent e32f2f4 commit 1c50de8
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions CommandFusion/CIPv1.0.js
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/*
CIP
Version:
1.0 - release
Supports standard XPanel features, with addition of serial transmit to control system.
Currently does not support Password protection, List protocol, and other custom messages such as Orientation.
Use:
Please visit http://www.github.com/CommandFusion/CIP for latest versions and help.
*/


Expand Down Expand Up @@ -153,29 +153,27 @@ var CIP = function(params){
case 0:
CF.setJoin("d" + self.DJoin_connectedFB, false);
self.log("Disconnected from IP ID: " + self.IPID,3,0);
self.clearJoins();
break;
case 1:
CF.setJoin("d" + self.DJoin_connectedFB, true);
self.log("Connected to IP ID: " + self.IPID,0,0);
self.heartBeatTimer = setTimeout(function(self){self.sendHeartBeat();},self.heartBeatRate, this);
self.updateRequestTimer = setTimeout(function(self){self.sendUpdateRequest();},self.updateRequestDebounce, this);
break;
case 2:
CF.setJoin("d" + self.DJoin_connectedFB, true);
self.log("Update Request Pending for IP ID: " + self.IPID,2,0);
self.heartBeatTimer = setTimeout(function(self){self.sendHeartBeat();},self.heartBeatRate, this);
self.updateRequestTimer = setTimeout(function(self){self.sendUpdateRequest();},self.updateRequestDebounce, this);
self.setPageJoin();
CF.setJoin("d" + self.DJoin_connectedFB, false);
self.log("IP ID Register Request, Sending: " + self.IPID,2,0);
self.sendMsg("\x01\x00\x07\x7F\x00\x00\x01\x00" + String.fromCharCode("0x" + self.IPID) + "\x40",0);
break;
case 3:
CF.setJoin("d" + self.DJoin_connectedFB, false);
clearTimeout(self.updateRequestTimer); //kill any update requests during debounce, helps when processor is booting up and sending multiple UR codes
self.log("IP ID Not Defined on Processor: " + self.IPID + ". Retrying...",3,0); //When program isn't fully booted on processor, it will reject
self.sendMsg("\x01\x00\x07\x7F\x00\x00\x01\x00" + String.fromCharCode("0x" + self.IPID) + "\x40",0);
break;
}
};



//Clear our join ranges on the UI
self.clearJoins = function () {
self.log("Clearing Joins...",1,0);
Expand Down Expand Up @@ -396,6 +394,7 @@ var CIP = function(params){
CF.setJoin(sJoin,self.SJValues[sJoin]);

} else if (dataType == 0x03) {
self.clearJoins();
//update request confirmation, we receive this just before processor sends the UR data.
} else if (dataType == 0x08) { //Date & Time - Only sent during update request, so driving a join would require a clock. Just for reference, for now.
var hour = payload.charCodeAt(5).toString(16);
Expand Down Expand Up @@ -444,6 +443,7 @@ var CIP = function(params){
CF.watch(CF.ConnectionStatusChangeEvent, self.systemName, self.onConnectionChange, true);
CF.watch(CF.FeedbackMatchedEvent, self.systemName, self.systemFeedbackName, self.receive);
CF.getGuiDescription(self.processGui);
//CF.watch(CF.GUIResumedEvent, self.onGUIResumed);

self.log( "\r\x09" + "CIP Ready for System: " + self.systemName + "\r" +
"\x09" + "Module Version: " + self.versionMajor + "." + self.versionMinor + "\r" +
Expand Down

1 comment on commit 1c50de8

@fpillet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.sendMsg("\x01\x00\x07\x7F\x00\x00\x01\x00" + String.fromCharCode("0x" + self.IPID) + "\x40",0);

This seems wrong to me. You should be writing: String.fromCharCode(self.IPID)

Please sign in to comment.