@@ -10,6 +10,7 @@ const SerialCommand = require('./serial');
10
10
const FlashCommand = require ( './flash' ) ;
11
11
const path = require ( 'path' ) ;
12
12
const _ = require ( 'lodash' ) ;
13
+ const { log } = require ( 'console' ) ;
13
14
14
15
// TODO: Get these from exports
15
16
const PROVISIONING_PROGRESS = 1 ;
@@ -18,7 +19,6 @@ const PROVISIONING_FAILURE = 3;
18
19
const CTRL_REQUEST_APP_CUSTOM = 10 ;
19
20
const GET_AT_COMMAND_STATUS = 4 ;
20
21
21
-
22
22
module . exports = class eSimCommands extends CLICommandBase {
23
23
constructor ( ) { // TODO: Bring ui class
24
24
super ( ) ;
@@ -106,6 +106,7 @@ module.exports = class eSimCommands extends CLICommandBase {
106
106
if ( ! flashResp . success ) {
107
107
return outputMsg ( ) ;
108
108
}
109
+ provisionOutputLogs . push ( `${ os . EOL } Firmware flashed successfully` ) ;
109
110
110
111
// Get the EID
111
112
const eidResp = await this . _getEid ( port ) ;
@@ -120,6 +121,11 @@ module.exports = class eSimCommands extends CLICommandBase {
120
121
const matchingEsim = this . inputJsonData . provisioning_data . find ( item => item . esim_id === eid ) ;
121
122
const iccidFromJson = matchingEsim . profiles . map ( ( profile ) => profile . iccid ) ;
122
123
expectedProfilesArray = matchingEsim . profiles ;
124
+
125
+ if ( ! matchingEsim || iccidFromJson ?. length === 0 || expectedProfilesArray ?. length === 0 ) {
126
+ provisionOutputLogs . push ( 'No profiles found for the given EID in the input JSON' ) ;
127
+ return outputMsg ( ) ;
128
+ }
123
129
124
130
const profileCmdResp = await this . _checkForExistingProfiles ( port ) ;
125
131
provisionOutputLogs . push ( ...profileCmdResp . output ) ;
@@ -129,6 +135,8 @@ module.exports = class eSimCommands extends CLICommandBase {
129
135
130
136
const profilesListOnDevice = profileCmdResp . profilesList ;
131
137
const existingIccids = profilesListOnDevice . map ( ( line ) => line . split ( '[' ) [ 1 ] . split ( ',' ) [ 0 ] . trim ( ) ) ;
138
+ provisionOutputLogs . push ( `${ os . EOL } profilesListOnDevice: ${ profilesListOnDevice } ` ) ;
139
+ provisionOutputLogs . push ( `${ os . EOL } existingIccids: ${ existingIccids } ` ) ;
132
140
133
141
if ( profilesListOnDevice . length > 0 ) {
134
142
// extract the iccids that belong to this EID
@@ -166,7 +174,8 @@ module.exports = class eSimCommands extends CLICommandBase {
166
174
167
175
// Download each profile and update the JSON output
168
176
await this . _changeLed ( device , PROVISIONING_PROGRESS ) ;
169
-
177
+
178
+ provisionOutputLogs . push ( `${ os . EOL } Downloading profiles...` ) ;
170
179
const downloadResp = await this . _doDownload ( profiles , port ) ;
171
180
const downloadedProfiles = downloadResp . downloadedProfiles ;
172
181
downloadedProfilesArray = downloadedProfiles . map ( ( profile ) => {
@@ -180,6 +189,7 @@ module.exports = class eSimCommands extends CLICommandBase {
180
189
provisionOutputLogs . push ( ...downloadResp . output ) ;
181
190
182
191
if ( ! downloadResp . success ) {
192
+ provisionOutputLogs . push ( 'Profile download failed' ) ;
183
193
return outputMsg ( ) ;
184
194
}
185
195
@@ -257,6 +267,7 @@ module.exports = class eSimCommands extends CLICommandBase {
257
267
// Flash the binary
258
268
const flashCmdInstance = new FlashCommand ( ) ;
259
269
270
+ logAndPush ( `${ os . EOL } Flashing firmware...` ) ;
260
271
await flashCmdInstance . flashLocal ( {
261
272
files : [ device . deviceId , fwPath ] ,
262
273
applicationOnly : true ,
@@ -277,7 +288,7 @@ module.exports = class eSimCommands extends CLICommandBase {
277
288
while ( Date . now ( ) - start < timeout && ! atOkReceived ) {
278
289
try {
279
290
const resp = await usbDevice . sendControlRequest ( CTRL_REQUEST_APP_CUSTOM , JSON . stringify ( GET_AT_COMMAND_STATUS ) ) ;
280
- console . log ( '[dbg] resp: ' , resp ) ;
291
+ // console.log('[dbg] resp: ', resp);
281
292
if ( resp ?. result === 0 && resp . data ?. [ 0 ] === '1' ) {
282
293
logAndPush ( 'AT-OK received' ) ;
283
294
atOkReceived = true ;
@@ -397,6 +408,7 @@ module.exports = class eSimCommands extends CLICommandBase {
397
408
}
398
409
} ) ;
399
410
} ;
411
+ logAndPush ( `${ os . EOL } Getting profiles for EID ${ eid } ...` ) ;
400
412
const eidBlock = this . inputJsonData . provisioning_data . find ( ( block ) => block . esim_id === eid ) ;
401
413
402
414
if ( ! eidBlock || ! eidBlock . profiles || eidBlock . profiles . length === 0 ) {
0 commit comments