@@ -90,6 +90,10 @@ export default class BoardConfiguration {
90
90
partialMessage = '' ;
91
91
this . daemon . writeSerial ( board . port , 'y\n' ) ;
92
92
}
93
+ if ( partialMessage . indexOf ( 'Please enter the thing id:' ) !== - 1 ) {
94
+ partialMessage = '' ;
95
+ this . daemon . writeSerial ( board . port , `${ board . deviceId } \n` ) ;
96
+ }
93
97
94
98
const begin = partialMessage . indexOf ( '-----BEGIN CERTIFICATE REQUEST-----' ) ;
95
99
const end = partialMessage . indexOf ( '-----END CERTIFICATE REQUEST-----' ) ;
@@ -121,13 +125,13 @@ export default class BoardConfiguration {
121
125
const notBefore = new Date ( compressedCert . not_before ) ;
122
126
const notAfter = new Date ( compressedCert . not_after ) ;
123
127
// eslint-disable-next-line prefer-template
124
- const answers = board . deviceId + '\n' +
125
- notBefore . getUTCFullYear ( ) + '\n' +
128
+ const answers = notBefore . getUTCFullYear ( ) + '\n' +
126
129
( notBefore . getUTCMonth ( ) + 1 ) + '\n' +
127
130
notBefore . getUTCDate ( ) + '\n' +
128
131
notBefore . getUTCHours ( ) + '\n' +
129
132
( notAfter . getUTCFullYear ( ) - notBefore . getUTCFullYear ( ) ) + '\n' +
130
133
compressedCert . serial + '\n' +
134
+ compressedCert . authority_key_identifier + '\n' +
131
135
compressedCert . signature + '\n' ;
132
136
this . daemon . writeSerial ( board . port , answers ) ;
133
137
} ) ;
@@ -168,7 +172,7 @@ export default class BoardConfiguration {
168
172
* @param {Object } board contains the board data
169
173
* @param {function } createDeviceCb used to create the device associated to the user
170
174
*/
171
- configure ( compiledSketch , board , createDeviceCb ) {
175
+ configure ( compiledSketch , board , createDeviceCb , generateCertificateCb ) {
172
176
this . daemon . initUpload ( ) ;
173
177
this . configuring . next ( { status : this . CONFIGURE_IN_PROGRESS , msg : 'Uploading provisioning sketch...' } ) ;
174
178
if ( ! this . daemon . channelOpen . getValue ( ) ) {
@@ -196,7 +200,7 @@ export default class BoardConfiguration {
196
200
this . daemon . uploadingDone . subscribe ( ( ) => {
197
201
this . configuring . next ( {
198
202
status : this . CONFIGURE_IN_PROGRESS ,
199
- msg : 'Provisioning sketch uploaded successfully. Opening serial monitor ...'
203
+ msg : 'Provisioning sketch uploaded successfully. Creating device ...'
200
204
} ) ;
201
205
this . daemon . serialMonitorOpened . pipe ( takeUntil ( this . daemon . serialMonitorOpened . pipe ( filter ( open => open ) ) ) )
202
206
. subscribe ( ( ) => {
@@ -208,14 +212,14 @@ export default class BoardConfiguration {
208
212
. then ( csr => {
209
213
this . configuring . next ( {
210
214
status : this . CONFIGURE_IN_PROGRESS ,
211
- msg : 'CSR generated. Creating device ...'
215
+ msg : 'CSR generated. Generating certificate ...'
212
216
} ) ;
213
- return createDeviceCb ( csr ) ;
217
+ return generateCertificateCb ( csr ) ;
214
218
} )
215
219
. then ( data => {
216
220
this . configuring . next ( {
217
221
status : this . CONFIGURE_IN_PROGRESS ,
218
- msg : 'Device created . Storing certificate...'
222
+ msg : 'Certificate generated . Storing certificate...'
219
223
} ) ;
220
224
return this . storeCertificate ( data . compressed , board ) ;
221
225
} )
@@ -234,7 +238,15 @@ export default class BoardConfiguration {
234
238
err : error . toString ( )
235
239
} ) ;
236
240
} ) ;
237
- this . daemon . openSerialMonitor ( board . port , BAUDRATE ) ;
241
+ createDeviceCb ( )
242
+ . then ( data => {
243
+ this . configuring . next ( {
244
+ status : this . CONFIGURE_IN_PROGRESS ,
245
+ msg : 'Device created. Opening serial monitor...'
246
+ } ) ;
247
+ board . deviceId = data . id ; // eslint-disable-line no-param-reassign
248
+ this . daemon . openSerialMonitor ( board . port , BAUDRATE ) ;
249
+ } ) ;
238
250
} ) ;
239
251
240
252
this . daemon . uploadingError . subscribe ( upload => {
0 commit comments