-
I see. Thanks for the feedback.
It is quite unusual to have to deal with SPI peripherals that doesn't exchange on 8-bit, however the Character display introduced here http://forum.espruino.com/conversations/313620/#comment13972928 is actually talking with 10-bit data... I'll try to bitbang it.
-
Just saw that SPI can send 4-bit nibbles (http://www.espruino.com/Reference#l_SPI_send4bit) or 8-bit bytes (http://www.espruino.com/Reference#l_SPI_send8bit).
What about 10-bit mode? -
-
-
Really? Well, this makes sense in term of power reduction. Anyway, reading this post: https://devzone.nordicsemi.com/question/64182/read-gpio-output-state/ I really seems that even on NRF52, an GPIO configured as an
output
can still be read. -
-
Hi,
Just tried to verify the state of a GPIO (D30):>pinMode(D30,'output') =undefined >getPinMode(D30) ="output" >digitalRead(D30) =0 >digitalWrite(D30,1) =undefined >digitalRead(D30) =0 >getPinMode(D30) ="output" >digitalWrite(D30,0) =undefined >digitalRead(D30) =0 >digitalWrite(D30,1) =undefined >digitalRead(D30) =0 >
I probed the pin, it actually goes high and low according to
digitalWrite
. Anyone knows why the state cannot be read by Espruino? -
I have a declared a function containing some debug code as well as a couple of comments. In addition, I added a comment area enclosed within
/*
and*/
. This gives something like that:function foo() { /*//a comment var myvar=0; //another comment */ }
Uncaught SyntaxError: Got UNFINISHED REGEX expected EOF
It seems that
/*//
are interpreted by the REGEX, isn't it? -
-
What about selling a "Espruino" version of this board, @gordon? https://www.tindie.com/products/marcaz/ble-5-nrf52832-development-board/?pt=ac_prod_search
For a public price of 16$, you should also be able to make some margin and reselling it, with Espruino inside for 20-25$?
-
Following this topic (https://devzone.nordicsemi.com/question/67300/writing-to-uicr-from-application-code/) it seems that the flash needs to be Write Enabled by writing 0x01 into
CONFIG
reg at addr0x4001E504
.
I usepoke32
for that, like following:var NVMCCONFIGreg=0x4001E504; poke32(NVMCCONFIGreg,0x00000001);
This instruction has the effect of disconnecting the Puck.js from the IDE (reset?)
Does anyone ever usedpoke32
on a NRF52? -
I just tried to unlock flash and write to the
NFCPINS
register with the latest build2017-11-27
:_____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |_____|___| _|_| |___|_|_|_|___| |_| http://espruino.com 1v94 Copyright 2017 G.Williams Espruino is Open Source. Our work is supported only by sales of official boards and donations: http://espruino.com/Donate >var f=require('Flash') =function () { [native code] } >var NFCPINSreg=0x1000120C =268440076 >var NFCPINSdata=[0xff,0xff,0xff,0xfe] =[ 255, 255, 255, 254 ] >E.getFlags() ={ "deepSleep": 0, "pretokenise": 0, "unsafeFlash": 0 } >E.setFlags({unsafeFlash:1}) =undefined >E.getFlags() ={ "deepSleep": 0, "pretokenise": 0, "unsafeFlash": 1 } >f.read(4,NFCPINSreg) =new Uint8Array([255, 255, 255, 255]) >f.write(NFCPINSdata,NFCPINSreg) =undefined >f.read(4,NFCPINSreg) =new Uint8Array([255, 255, 255, 255])
Despite the flag
unsafeFlash
being set to 1, it seems that the flash register did not change. Any idea? -
-
-
-
You already had such a case here : http://forum.espruino.com/comments/13436240/
-
-
-
In order to use P0.09 and P0.10 as GPIOs (requires to "cut" the NFC antenna in order to remove the intrinsic short circuit made by the antenna), one must write into
NFCPINS
register (addr offset 0x20C) the value0x00000000
in order to disable NFC on those pins. (ref: http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/uicr.html#register.NFCPINS )
On STM32 chips there are peek/poke functions for register access. What about the NRF52? -
Just to rule anything out, could you try calling startBonding after connect, and then try and read the information after that?
IMO it is not necessary, I am quite sure it is bonded now. Furthermore, I can discover services with
function Discover(){ gatt.getPrimaryServices().then(function(services) { console.log("Services:",services); }).catch(function(e){console.log("error: ",e);}); }
with the corresponding log:
Services: [ BluetoothRemoteGATTService { "uuid": "0x1800", "isPrimary": true, "start_handle": 1, "end_handle": 7 }, BluetoothRemoteGATTService { "uuid": "0x1801", "isPrimary": true, "start_handle": 8, "end_handle": 11 }, BluetoothRemoteGATTService { "uuid": "0x0000[vendor]", "isPrimary": true, "start_handle": 12, "end_handle": 21 }, BluetoothRemoteGATTService { "uuid": "0x180a", "isPrimary": true, "start_handle": 22, "end_handle": 34 }, BluetoothRemoteGATTService { "uuid": "0x0000[vendor]", "isPrimary": true, "start_handle": 35, "end_handle": 44 }, BluetoothRemoteGATTService { "uuid": "0x0000[vendor]", "isPrimary": true, "start_handle": 45, "end_handle": 65535 } ]
Actually 3 services with proprietary UUIDs are listed with
0x0000[vendor]
. I suspect that it is the reason why I can't exchange with those services...I just made a READ request on the "Generic Access" service (0x1800), characteristic "Device Name" (0x2A00) and I am able to retrieve the correct device name.
-
OK I have good news: I can open and maintain a connection with the actuator !
Once again, you were right @Gordon, it was due to a refused bonding. When I discovered the paramforceRePair
of thestartBonding()
method I immediately tried to set it to1
and ... it worked.Now I cannot read any value , including mandatory fields such as DeviceInfo.ModelNumber (0x180A-->0x2A24). However I am strictly following the example given in the doc http://www.espruino.com/Reference#l_BluetoothRemoteGATTCharacteristic_readValue :
var device; NRF.connect(device_address).then(function(d) { device = d; return d.getPrimaryService("service_uuid"); }).then(function(s) { console.log("Service ",s); return s.getCharacteristic("characteristic_uuid"); }).then(function(c) { return c.readValue(); }).then(function(d) { console.log("Got:", JSON.stringify(d.buffer)); device.disconnect(); }).catch(function() { console.log("Something's broken."); });
I always receive an empty buffer . I tried to retrieve this value with NrfConnect and this works well.
By the way, I am experiencing disconnections between the IDE and the puck sometimes (I would say every 4-5 minutes after having reseted the puck), even if I don't download any script in it. Is it a feature to keep the consumption low, or an issue in my setup?
-
Just trying your code, it gives me this log:
>Connect2(MyDev) =undefined BluetoothRemoteGATTServer { "device": BluetoothDevice { "id": "96:05:05:f7:ac:1c random", "rssi": -54, "services": [ ], "data": new Uint8Array([2, 1, 4, 12, 9, 72, 75, 73, 18, 45, 54, 30, 54, 48, 49, 57]).buffer, "name": "MyActuator", "gatt": ... }, "connected": true } delayed for 1000ms... BluetoothRemoteGATTServer { "device": BluetoothDevice { "id": "96:05:05:f7:ac:1c random", "rssi": -54, "services": [ ], "data": new Uint8Array([2, 1, 4, 12, 9, 72, 75, 73, 18, 45, 54, 30, 54, 48, 49, 57]).buffer, "name": "MyActuator", "gatt": ... }, "connected": false } end delay - getPrimaryService Uncaught Error: Unhandled promise rejection: Not connected >
I just tried with the smartphone of a colleague (Samsung galaxy S5), he just can't connect to it. Therefore, I will investigate the whitelisting/bonding topic.
It's a shame I cannot use the nrf sniffer (PCA100028) that I just received, it seem to have a problem with the Segger driver version, that seems to be too recent :-/ -
Well, nice try but no difference, gatt is disconnected after the 1000ms delay.
function Connect(dev){ NRF.requestDevice({ filters: [{ name: Devname }] }).then(function(device) { return device.gatt.connect(); }).then(function(g) { gatt = g; console.log(gatt); return new Promise(function(resolve) { setTimeout(resolve, 1000); console.log("delayed for 1000ms..."); }); }).then(function() { console.log("end delay"); return gatt.getPrimaryService(serviceUUID); }).then(function(service) { return service.getCharacteristic(characteristicUUID); }).then(function(characteristic) { return characteristic.writeValue(MessageToSend); }).then(function() { console.log("Done!"); }); }
Which, when executed, gives:
>Connect(MyDev) =undefined BluetoothRemoteGATTServer { "device": BluetoothDevice { "id": "96:05:05:f7:ac:1c random", "rssi": -64, "services": [ ], "data": new Uint8Array([2, 1, 4, 12, 9, 72, 75, 73, 18, 45, 54, 30, 54, 48, 49, 57]).buffer, "name": "MyActuator", "gatt": ... }, "connected": true } delayed for 1000ms... end delay Uncaught Error: Unhandled promise rejection: Not connected >
I really can't understand why it connects THEN disconnects quickly.
-
It seems that nrf52 gpio input registers can't be read if gpio is set as output. Anyway, for a LED, which does have the exact logic level you previously imposed to it ( which may not be the case if output is open drain and used for communication such as I2C) , you should be able to get the current status of the LED by using the
peek()
method on the OUTPUT register, because digitalRead() won't work as it may poll INPUT register only.