Skip to content

Commit

Permalink
Add TI-Nspire PTT Exit command (fixme: better ack/reset)
Browse files Browse the repository at this point in the history
  • Loading branch information
adriweb committed Mar 12, 2018
1 parent 1e99353 commit 861a3f0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ <h4 class="card-header">calc name</h4>
<button class="btn btn-primary btn-sm" data-action="sendFile" disabled><i class="fa fa-upload" aria-hidden="true"></i> Send file...</button>
<button class="btn btn-primary btn-sm" data-action="sendKey" disabled><i class="fa fa-keyboard-o" aria-hidden="true"></i> Send key...</button>
<button class="btn btn-primary btn-sm" data-action="dumpRom" disabled><i class="fa fa-microchip" aria-hidden="true"></i> Dump ROM</button>
<button class="btn btn-primary btn-sm" data-action="exitPTT" disabled><i class="fa fa-graduation-cap" aria-hidden="true"></i> Exit PTT</button>
<button class="btn btn-primary btn-sm" data-action="exitPTT"><i class="fa fa-graduation-cap" aria-hidden="true"></i> Exit PTT</button>
</div>
<hr>
<p class="card-text"><b>USB raw frames log</b>:
Expand Down
25 changes: 25 additions & 0 deletions webusbti.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ function findOrCreateDevice(rawDevice)
case 'ready':
$btn.on('click', () => { device.readySequence() });
break;
case 'exitPTT':
$btn.on('click', () => { device.exitPTT() });
break;
}
});

Expand Down Expand Up @@ -205,6 +208,28 @@ function findOrCreateDevice(rawDevice)
.then(() => this.disconnect());
};

webusb.Device.prototype.exitPTT = function ()
{
this.connect().then(async () =>
{
// array of: [ hexStr, readCountAfter ]
const seq = [
[ "54fd64004003640140031343040001fb6401ff00", 0 ], // addr assign
[ "54fd640080016401409031ab0a00015200000004010000000000", 1 ], // remote mgmt, exit ptt
[ "54fd640080016401409031ab0a00015200000004010000000000", 1 ], // twice because invalid seq first
[ "54fd640080016401409027230a0001c000000006010000000000", 1 ] // reset (fixme, probably bad seq/sum)
];
for (const frame of seq)
{
await this.transferOut(hexStrToArrayBuffer(frame[0]));
for (let i=0; i<frame[1]; i++) {
await this.transferIn().then(this.responseHandler.bind(this));
}
}
})
.then(() => this.disconnect());
};

})();


Expand Down

0 comments on commit 861a3f0

Please sign in to comment.