Skip to content

Commit 7d1a712

Browse files
committed
Use simple check in correct place of firmware file thanks to @fanoush - 6cf5a74#commitcomment-165215201
1 parent 6cf5a74 commit 7d1a712

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

ChangeLog

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
nRF52: Fix gatt.setRSSIHandler on the first active connection
1515
Added i2cRead/WriteReg for simplified internal I2C code
1616
Bangle.js2: Support for new Bangles with MMC36X0 magnetometer (Bangle.dbg() now shows info)
17-
nRF52840: Add process.env.SOFTDEVICE for detecting which softdevice version is installed
17+
nRF5x: Add process.env.SOFTDEVICE for detecting which softdevice version is installed
1818

1919
2v27 : nRF5x: Ensure Bluetooth notifications work correctly when two separate connections use the same handle for their characteristics
2020
nRF5x: Remove handlers from our handlers array when a device is disconnected

src/jswrap_process.c

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,17 @@ Returns an Object containing various pre-defined variables.
122122
* `APP_RAM_BASE` - On nRF5x boards, this is the RAM required by the Softdevice
123123
*if it doesn't exactly match what was allocated*. You can use this to update
124124
`LD_APP_RAM_BASE` in the `BOARD.py` file
125-
* `SOFTDEVICE` - (on nRF52840) the version of Bluetooth Softdevice that is installed on
126-
the device, usually `"6.0.0"` or `"6.1.1"`
125+
* `SOFTDEVICE` - (on nRF5x) the hex version code of the Bluetooth Softdevice that is installed on the device (see below)
127126
128-
For example, to get a list of built-in modules, you can use
129-
`process.env.MODULES.split(',')`
127+
To get a list of built-in modules, you can use `process.env.MODULES.split(',')`
128+
129+
The `process.env.SOFTDEVICE` code is likely one of:
130+
131+
| Code | Chip | Softdevice |
132+
|--------------|----------|-----------------------|
133+
| 0x0091 / 145 | nRF52832 | S132 v3.1.0 (SDK12) |
134+
| 0x00A9 / 169 | nRF52840 | S140 v6.0.0 (SDK15.3) |
135+
| 0x00B6 / 182 | nRF52840 | S140 v6.1.1 (SDK15) |
130136
131137
**Note:** `process.env` is not writeable - so as not to waste RAM, the contents
132138
are generated on demand. If you need to be able to change them, use `process.env=process.env;`
@@ -162,17 +168,8 @@ JsVar *jswrap_process_env() {
162168
if (app_ram_base)
163169
jsvObjectSetChildAndUnLock(obj, "APP_RAM_BASE", jsvNewFromInteger((JsVarInt)app_ram_base));
164170
#endif
165-
#ifdef NRF52840
166-
// Do a CRC of the 32 bytes from offset 256 (in the softdevice area), eg E.CRC32(E.memoryArea(256,32))
167-
const char *softdevice = "unknown";
168-
JsVar *sdArea = jswrap_espruino_memoryArea(256,32);
169-
uint32_t crc = (uint32_t)jsvGetIntegerAndUnLock(jswrap_espruino_CRC32(sdArea));
170-
jsvUnLock(sdArea);
171-
// compare with known values
172-
if (crc == 3039104175) softdevice = "6.0.0";
173-
if (crc == 2754746215) softdevice = "6.1.1";
174-
jsvObjectSetChildAndUnLock(obj, "SOFTDEVICE", jsvNewFromString(softdevice));
175-
#endif
171+
// https://devzone.nordicsemi.com/f/nordic-q-a/1171/how-do-i-access-softdevice-version-string
172+
jsvObjectSetChildAndUnLock(obj, "SOFTDEVICE", jsvNewFromInteger(*(uint16_t*)0x0000300C));
176173
#endif
177174
return obj;
178175
}

0 commit comments

Comments
 (0)