@@ -122,6 +122,8 @@ Returns an Object containing various pre-defined variables.
122
122
* `APP_RAM_BASE` - On nRF5x boards, this is the RAM required by the Softdevice
123
123
*if it doesn't exactly match what was allocated*. You can use this to update
124
124
`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
127
126
128
For example, to get a list of built-in modules, you can use
127
129
`process.env.MODULES.split(',')`
@@ -160,6 +162,17 @@ JsVar *jswrap_process_env() {
160
162
if (app_ram_base )
161
163
jsvObjectSetChildAndUnLock (obj , "APP_RAM_BASE" , jsvNewFromInteger ((JsVarInt )app_ram_base ));
162
164
#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
163
176
#endif
164
177
return obj ;
165
178
}
0 commit comments