@@ -28,6 +28,11 @@ var microbitFsWrapper = function() {
2828 'size' ,
2929 'write' ,
3030 ] ;
31+ var v1BoardIds = [ '9900' , '9901' ] ;
32+ var v2BoardIds = [ '9903' , '9904' , '9905' , '9906' ] ;
33+ // TODO: We need to use ID 9901 for mobile app compatibility, but can soon be changed to 9900 (as per spec)
34+ var hexBoardIdV1 = 0x9901 ;
35+ var hexBoardIdV2 = microbitFs . microbitBoardId . V2 ;
3136
3237 /**
3338 * Duplicates some of the methods from the MicropythonFsHex class by
@@ -64,10 +69,9 @@ var microbitFsWrapper = function() {
6469 if ( ! uPyV1 || ! uPyV2 ) {
6570 console . error ( 'There was an issue loading the MicroPython Hex files.' ) ;
6671 }
67- // TODO: We need to use ID 9901 for app compatibility, but can soon be changed to 9900 (as per spec)
6872 uPyFs = new microbitFs . MicropythonFsHex ( [
69- { hex : uPyV1 , boardId : 0x9901 } ,
70- { hex : uPyV2 , boardId : 0x9903 } ,
73+ { hex : uPyV1 , boardId : hexBoardIdV1 } ,
74+ { hex : uPyV2 , boardId : hexBoardIdV2 } ,
7175 ] , {
7276 'maxFsSize' : commonFsSize ,
7377 } ) ;
@@ -80,10 +84,10 @@ var microbitFsWrapper = function() {
8084 * @returns Uint8Array with the data for the given Board ID.
8185 */
8286 fsWrapper . getBytesForBoardId = function ( boardId ) {
83- if ( boardId == '9900' || boardId == '9901' ) {
84- return uPyFs . getIntelHexBytes ( 0x9901 ) ;
85- } else if ( boardId == '9903' || boardId == '9904' ) {
86- return uPyFs . getIntelHexBytes ( 0x9903 ) ;
87+ if ( v1BoardIds . indexOf ( boardId ) >= 0 ) {
88+ return uPyFs . getIntelHexBytes ( hexBoardIdV1 ) ;
89+ } else if ( v2BoardIds . indexOf ( boardId ) >= 0 ) {
90+ return uPyFs . getIntelHexBytes ( hexBoardIdV2 ) ;
8791 } else {
8892 throw Error ( 'Could not recognise the Board ID ' + boardId ) ;
8993 }
@@ -94,10 +98,10 @@ var microbitFsWrapper = function() {
9498 * @returns ArrayBuffer with the Intel Hex data for the given Board ID.
9599 */
96100 fsWrapper . getIntelHexForBoardId = function ( boardId ) {
97- if ( boardId == '9900' || boardId == '9901' ) {
98- var hexStr = uPyFs . getIntelHex ( 0x9901 ) ;
99- } else if ( boardId == '9903' || boardId == '9904' ) {
100- var hexStr = uPyFs . getIntelHex ( 0x9903 ) ;
101+ if ( v1BoardIds . indexOf ( boardId ) >= 0 ) {
102+ var hexStr = uPyFs . getIntelHex ( hexBoardIdV1 ) ;
103+ } else if ( v2BoardIds . indexOf ( boardId ) >= 0 ) {
104+ var hexStr = uPyFs . getIntelHex ( hexBoardIdV2 ) ;
101105 } else {
102106 throw Error ( 'Could not recognise the Board ID ' + boardId ) ;
103107 }
0 commit comments