@@ -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
132138are 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