You are reading a single comment by @ThePlayShed and its replies.
Click here to read the full conversation.
-
Hello James, any chance you would re-edit your code posting so that line numbers will appear along with color hilighting?
Hilight the code block, then click the < / > code button between the Quote button and Preview button,
or,
Place three backticks (below the tilde key and next to the numeral 1 key) just before and just after the code block.
This will enhance and make reading easier.
Hi All
Thanks allobjects that helped but my progress is still quite slow, i have managed to connect to the train and disconnect but can't work out the best way to send the buffer. I am still trying to get my head around javascript so maybe missing something quite obvious
here's my current code
var devices;
var gatt;
var DevName="e0:7d:ea:0c:03:29";
var serviceUUID="00001623-1212-efde-1623-785feabcd123";
var characteristicUUID="00001624-1212-efde-1623-785feabcd123";
var MessageToSend=[0x81, 0x00, 0x11, 0x51, 0x00, 0x64];
pinMode(D15, 'input_pulldown');
global.LED2=D2;
NRF.connect("e0:7d:ea:0c:03:29").then(function(g) {
console.log("Starting connecting");
gatt = g;
return gatt.getPrimaryService("00001623-1212-efde-1623-785feabcd123");
}).then(function(service) {
return service.getCharacteristic("00001624-1212-efde-1623-785feabcd123");
}).then(function(characteristic) {
return characteristic.writeValue(MessageToSend);
}).then(function() {
//gatt.disconnect();
console.log("Done!");
});
function send_message() {
console.log("Moving Train");
NRF.nfcSend(new Uint8Array([0x81, 0x00, 0x11, 0x51, 0x00, 0x64]));
}
function train_disconnect() {
console.log("Disconnecting");
gatt.disconnect();
}
setInterval(function() {
digitalWrite(LED2, digitalRead(D15));
if (digitalRead(D15) == 1) {
}
console.log("Button pressed", digitalRead(D15));
}, 300);
any advice would be greatly appreciated
Cheers
James