File tree Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Expand file tree Collapse file tree 3 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 15
15
export const FICR = {
16
16
CODEPAGESIZE : 0x10000000 | 0x10 ,
17
17
CODESIZE : 0x10000000 | 0x14 ,
18
+
19
+ DEVICE_ID_1 : 0x10000000 | 0x64 ,
18
20
} ;
19
21
20
22
export const DapCmd = {
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ export class DAPWrapper {
28
28
29
29
_pageSize : number | undefined ;
30
30
_numPages : number | undefined ;
31
+ _deviceId : number | undefined ;
31
32
32
33
private loggedBoardSerialInfo : BoardSerialInfo | undefined ;
33
34
@@ -62,6 +63,13 @@ export class DAPWrapper {
62
63
return this . _numPages ;
63
64
}
64
65
66
+ /**
67
+ * The number of pages. Undefined if we've not connected.
68
+ */
69
+ get deviceId ( ) {
70
+ return this . _deviceId ;
71
+ }
72
+
65
73
get boardSerialInfo ( ) : BoardSerialInfo {
66
74
return BoardSerialInfo . parse (
67
75
this . device ,
@@ -112,6 +120,8 @@ export class DAPWrapper {
112
120
113
121
this . _pageSize = await this . cortexM . readMem32 ( FICR . CODEPAGESIZE ) ;
114
122
this . _numPages = await this . cortexM . readMem32 ( FICR . CODESIZE ) ;
123
+ // https://support.microbit.org/support/solutions/articles/19000067679-how-to-find-the-name-of-your-micro-bit
124
+ this . _deviceId = await this . cortexM . readMem32 ( FICR . DEVICE_ID_1 ) ;
115
125
}
116
126
117
127
async startSerial ( listener : ( data : string ) => void ) : Promise < void > {
Original file line number Diff line number Diff line change @@ -196,6 +196,10 @@ export class MicrobitWebUSBConnection
196
196
} ) ;
197
197
}
198
198
199
+ getDeviceId ( ) : number | undefined {
200
+ return this . connection ?. deviceId ;
201
+ }
202
+
199
203
getBoardVersion ( ) : BoardVersion | undefined {
200
204
return this . connection ?. boardSerialInfo ?. id . toBoardVersion ( ) ;
201
205
}
You can’t perform that action at this time.
0 commit comments