@nordicsemiconductor/pc-nrfconnect-shared 129.0.0 → 131.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Changelog.md CHANGED
@@ -7,6 +7,30 @@ This project does _not_ adhere to
7
7
  [Semantic Versioning](https://semver.org/spec/v2.0.0.html) but contrary to it
8
8
  every new version is a new major version.
9
9
 
10
+ ## 131 - 2023-11-14
11
+
12
+ ### Changed
13
+
14
+ - Storage key `isSendingUsageData` → `isSendingTelemetry`. The consequence of
15
+ this is that telemetry is only sent after users again agree to it, which is
16
+ required because we changed the agreement from Google Analytics to Microsoft
17
+ Azure.
18
+
19
+ ### Fixed
20
+
21
+ - Removed warning from `applicationinsights` in the console on start.
22
+
23
+ ## 130 - 2023-11-14
24
+
25
+ ### Fixed
26
+
27
+ - Ensure that all enumerated devices are always processed in order to avoid:
28
+ - calling nrfutil device-info multiple times for the same device
29
+ - only calling onSuccess once when waiting for device when rebooting
30
+ - `nrfutil device` now calls `device-info` before notifying the app with an
31
+ onSelectedDevice. This is to ensure the operations to the device are
32
+ completed before the app possibly does any more action on it
33
+
10
34
  ## 129 - 2023-11-13
11
35
 
12
36
  ### Added
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" ?>
2
2
  <!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
3
- <coverage lines-valid="3565" lines-covered="1904" line-rate="0.534" branches-valid="1779" branches-covered="511" branch-rate="0.2872" timestamp="1699876812179" complexity="0" version="0.1">
3
+ <coverage lines-valid="3577" lines-covered="1905" line-rate="0.5325" branches-valid="1781" branches-covered="511" branch-rate="0.2869" timestamp="1699966095971" complexity="0" version="0.1">
4
4
  <sources>
5
5
  <source>/home/vsts/work/1/s</source>
6
6
  </sources>
@@ -2879,7 +2879,7 @@
2879
2879
  </class>
2880
2880
  </classes>
2881
2881
  </package>
2882
- <package name="src.Device" line-rate="0.35359999999999997" branch-rate="0.193">
2882
+ <package name="src.Device" line-rate="0.3492" branch-rate="0.192">
2883
2883
  <classes>
2884
2884
  <class name="deviceAutoSelectSlice.ts" filename="src/Device/deviceAutoSelectSlice.ts" line-rate="0.6111" branch-rate="0.2857">
2885
2885
  <methods>
@@ -3031,7 +3031,7 @@
3031
3031
  <line number="153" hits="8" branch="false"/>
3032
3032
  </lines>
3033
3033
  </class>
3034
- <class name="deviceLister.ts" filename="src/Device/deviceLister.ts" line-rate="0.223" branch-rate="0.0784">
3034
+ <class name="deviceLister.ts" filename="src/Device/deviceLister.ts" line-rate="0.2112" branch-rate="0.07690000000000001">
3035
3035
  <methods>
3036
3036
  <method name="(anonymous_5)" hits="0" signature="()V">
3037
3037
  <lines>
@@ -3085,102 +3085,117 @@
3085
3085
  </method>
3086
3086
  <method name="(anonymous_18)" hits="0" signature="()V">
3087
3087
  <lines>
3088
- <line number="166" hits="0"/>
3088
+ <line number="167" hits="0"/>
3089
3089
  </lines>
3090
3090
  </method>
3091
3091
  <method name="(anonymous_19)" hits="0" signature="()V">
3092
3092
  <lines>
3093
- <line number="174" hits="0"/>
3093
+ <line number="173" hits="0"/>
3094
3094
  </lines>
3095
3095
  </method>
3096
3096
  <method name="(anonymous_20)" hits="0" signature="()V">
3097
3097
  <lines>
3098
- <line number="198" hits="0"/>
3098
+ <line number="181" hits="0"/>
3099
3099
  </lines>
3100
3100
  </method>
3101
3101
  <method name="(anonymous_21)" hits="0" signature="()V">
3102
3102
  <lines>
3103
- <line number="296" hits="0"/>
3103
+ <line number="206" hits="0"/>
3104
3104
  </lines>
3105
3105
  </method>
3106
3106
  <method name="(anonymous_22)" hits="0" signature="()V">
3107
3107
  <lines>
3108
- <line number="299" hits="0"/>
3108
+ <line number="309" hits="0"/>
3109
3109
  </lines>
3110
3110
  </method>
3111
3111
  <method name="(anonymous_23)" hits="0" signature="()V">
3112
3112
  <lines>
3113
- <line number="313" hits="0"/>
3113
+ <line number="310" hits="0"/>
3114
3114
  </lines>
3115
3115
  </method>
3116
- <method name="(anonymous_24)" hits="1" signature="()V">
3116
+ <method name="(anonymous_24)" hits="0" signature="()V">
3117
3117
  <lines>
3118
- <line number="348" hits="1"/>
3118
+ <line number="320" hits="0"/>
3119
3119
  </lines>
3120
3120
  </method>
3121
3121
  <method name="(anonymous_25)" hits="0" signature="()V">
3122
3122
  <lines>
3123
- <line number="351" hits="0"/>
3123
+ <line number="323" hits="0"/>
3124
3124
  </lines>
3125
3125
  </method>
3126
3126
  <method name="(anonymous_26)" hits="0" signature="()V">
3127
3127
  <lines>
3128
- <line number="355" hits="0"/>
3128
+ <line number="337" hits="0"/>
3129
3129
  </lines>
3130
3130
  </method>
3131
- <method name="(anonymous_27)" hits="21" signature="()V">
3131
+ <method name="(anonymous_27)" hits="1" signature="()V">
3132
3132
  <lines>
3133
- <line number="361" hits="21"/>
3133
+ <line number="372" hits="1"/>
3134
3134
  </lines>
3135
3135
  </method>
3136
3136
  <method name="(anonymous_28)" hits="0" signature="()V">
3137
3137
  <lines>
3138
- <line number="362" hits="0"/>
3138
+ <line number="375" hits="0"/>
3139
3139
  </lines>
3140
3140
  </method>
3141
3141
  <method name="(anonymous_29)" hits="0" signature="()V">
3142
3142
  <lines>
3143
- <line number="369" hits="0"/>
3143
+ <line number="379" hits="0"/>
3144
3144
  </lines>
3145
3145
  </method>
3146
- <method name="(anonymous_30)" hits="0" signature="()V">
3146
+ <method name="(anonymous_30)" hits="21" signature="()V">
3147
3147
  <lines>
3148
- <line number="374" hits="0"/>
3148
+ <line number="385" hits="21"/>
3149
3149
  </lines>
3150
3150
  </method>
3151
3151
  <method name="(anonymous_31)" hits="0" signature="()V">
3152
3152
  <lines>
3153
- <line number="380" hits="0"/>
3153
+ <line number="386" hits="0"/>
3154
3154
  </lines>
3155
3155
  </method>
3156
3156
  <method name="(anonymous_32)" hits="0" signature="()V">
3157
3157
  <lines>
3158
- <line number="381" hits="0"/>
3158
+ <line number="393" hits="0"/>
3159
3159
  </lines>
3160
3160
  </method>
3161
3161
  <method name="(anonymous_33)" hits="0" signature="()V">
3162
3162
  <lines>
3163
- <line number="382" hits="0"/>
3163
+ <line number="398" hits="0"/>
3164
+ </lines>
3165
+ </method>
3166
+ <method name="(anonymous_34)" hits="0" signature="()V">
3167
+ <lines>
3168
+ <line number="404" hits="0"/>
3169
+ </lines>
3170
+ </method>
3171
+ <method name="(anonymous_35)" hits="0" signature="()V">
3172
+ <lines>
3173
+ <line number="405" hits="0"/>
3164
3174
  </lines>
3165
3175
  </method>
3166
3176
  <method name="(anonymous_36)" hits="0" signature="()V">
3167
3177
  <lines>
3168
- <line number="386" hits="0"/>
3178
+ <line number="406" hits="0"/>
3169
3179
  </lines>
3170
3180
  </method>
3171
- <method name="(anonymous_37)" hits="0" signature="()V">
3181
+ <method name="(anonymous_39)" hits="0" signature="()V">
3172
3182
  <lines>
3173
- <line number="408" hits="0"/>
3183
+ <line number="410" hits="0"/>
3174
3184
  </lines>
3175
3185
  </method>
3176
- <method name="(anonymous_38)" hits="0" signature="()V">
3186
+ <method name="(anonymous_40)" hits="0" signature="()V">
3187
+ <lines>
3188
+ <line number="432" hits="0"/>
3189
+ </lines>
3190
+ </method>
3191
+ <method name="(anonymous_41)" hits="0" signature="()V">
3177
3192
  <lines>
3178
- <line number="411" hits="0"/>
3193
+ <line number="435" hits="0"/>
3179
3194
  </lines>
3180
3195
  </method>
3181
- <method name="(anonymous_39)" hits="22" signature="()V">
3196
+ <method name="(anonymous_42)" hits="22" signature="()V">
3182
3197
  <lines>
3183
- <line number="423" hits="22"/>
3198
+ <line number="447" hits="22"/>
3184
3199
  </lines>
3185
3200
  </method>
3186
3201
  </methods>
@@ -3236,85 +3251,97 @@
3236
3251
  <line number="157" hits="11" branch="false"/>
3237
3252
  <line number="165" hits="11" branch="false"/>
3238
3253
  <line number="166" hits="11" branch="false"/>
3239
- <line number="167" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3254
+ <line number="167" hits="11" branch="false"/>
3240
3255
  <line number="168" hits="0" branch="false"/>
3241
- <line number="172" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3242
- <line number="175" hits="0" branch="true" condition-coverage="0% (0/3)"/>
3243
- <line number="180" hits="0" branch="false"/>
3244
- <line number="184" hits="0" branch="false"/>
3245
- <line number="185" hits="0" branch="false"/>
3246
- <line number="186" hits="0" branch="false"/>
3247
- <line number="188" hits="0" branch="false"/>
3248
- <line number="196" hits="0" branch="false"/>
3249
- <line number="197" hits="0" branch="false"/>
3250
- <line number="198" hits="0" branch="false"/>
3251
- <line number="201" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3252
- <line number="205" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3253
- <line number="210" hits="0" branch="false"/>
3254
- <line number="214" hits="0" branch="false"/>
3256
+ <line number="169" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3257
+ <line number="170" hits="0" branch="false"/>
3258
+ <line number="173" hits="0" branch="false"/>
3259
+ <line number="174" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3260
+ <line number="175" hits="0" branch="false"/>
3261
+ <line number="179" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3262
+ <line number="182" hits="0" branch="true" condition-coverage="0% (0/3)"/>
3263
+ <line number="187" hits="0" branch="false"/>
3264
+ <line number="191" hits="0" branch="false"/>
3265
+ <line number="192" hits="0" branch="false"/>
3266
+ <line number="193" hits="0" branch="false"/>
3267
+ <line number="195" hits="0" branch="false"/>
3268
+ <line number="203" hits="0" branch="false"/>
3269
+ <line number="205" hits="0" branch="false"/>
3270
+ <line number="206" hits="0" branch="false"/>
3271
+ <line number="209" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3272
+ <line number="213" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3255
3273
  <line number="218" hits="0" branch="false"/>
3256
- <line number="221" hits="0" branch="false"/>
3257
3274
  <line number="222" hits="0" branch="false"/>
3258
- <line number="223" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3259
- <line number="228" hits="0" branch="false"/>
3275
+ <line number="226" hits="0" branch="false"/>
3276
+ <line number="229" hits="0" branch="false"/>
3260
3277
  <line number="230" hits="0" branch="false"/>
3261
- <line number="244" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3262
- <line number="252" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3263
- <line number="269" hits="0" branch="false"/>
3264
- <line number="274" hits="0" branch="false"/>
3265
- <line number="276" hits="0" branch="false"/>
3266
- <line number="278" hits="0" branch="false"/>
3267
- <line number="282" hits="0" branch="false"/>
3268
- <line number="283" hits="0" branch="false"/>
3269
- <line number="285" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3278
+ <line number="231" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3279
+ <line number="236" hits="0" branch="false"/>
3280
+ <line number="238" hits="0" branch="false"/>
3281
+ <line number="252" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3282
+ <line number="262" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3283
+ <line number="279" hits="0" branch="false"/>
3284
+ <line number="284" hits="0" branch="false"/>
3270
3285
  <line number="286" hits="0" branch="false"/>
3271
- <line number="290" hits="0" branch="false"/>
3272
- <line number="296" hits="11" branch="false"/>
3273
- <line number="297" hits="0" branch="false"/>
3274
- <line number="299" hits="0" branch="false"/>
3275
- <line number="300" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3286
+ <line number="288" hits="0" branch="false"/>
3287
+ <line number="294" hits="0" branch="false"/>
3288
+ <line number="295" hits="0" branch="false"/>
3289
+ <line number="297" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3290
+ <line number="298" hits="0" branch="false"/>
3276
3291
  <line number="302" hits="0" branch="false"/>
3277
- <line number="303" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3278
- <line number="308" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3279
3292
  <line number="309" hits="0" branch="false"/>
3293
+ <line number="310" hits="0" branch="false"/>
3280
3294
  <line number="311" hits="0" branch="false"/>
3295
+ <line number="312" hits="0" branch="false"/>
3296
+ <line number="313" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3281
3297
  <line number="314" hits="0" branch="false"/>
3282
- <line number="325" hits="0" branch="false"/>
3283
- <line number="334" hits="0" branch="false"/>
3284
- <line number="336" hits="0" branch="false"/>
3285
- <line number="348" hits="11" branch="false"/>
3286
- <line number="349" hits="1" branch="false"/>
3287
- <line number="352" hits="0" branch="false"/>
3288
- <line number="353" hits="0" branch="false"/>
3289
- <line number="356" hits="0" branch="false"/>
3290
- <line number="361" hits="1" branch="false"/>
3291
- <line number="362" hits="21" branch="false"/>
3292
- <line number="363" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3293
- <line number="369" hits="2" branch="false"/>
3294
- <line number="373" hits="0" branch="false"/>
3295
- <line number="374" hits="0" branch="false"/>
3296
- <line number="375" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3297
- <line number="380" hits="2" branch="false"/>
3298
- <line number="381" hits="0" branch="false"/>
3299
- <line number="382" hits="0" branch="false"/>
3300
- <line number="386" hits="0" branch="true" condition-coverage="0% (0/4)"/>
3301
- <line number="390" hits="0" branch="true" condition-coverage="0% (0/3)"/>
3302
- <line number="391" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3303
- <line number="392" hits="0" branch="false"/>
3304
- <line number="395" hits="0" branch="false"/>
3305
- <line number="398" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3306
- <line number="399" hits="0" branch="false"/>
3307
- <line number="402" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3308
- <line number="403" hits="0" branch="false"/>
3309
- <line number="408" hits="2" branch="false"/>
3310
- <line number="411" hits="0" branch="false"/>
3311
- <line number="412" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3312
- <line number="413" hits="0" branch="false"/>
3313
- <line number="417" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3298
+ <line number="318" hits="0" branch="false"/>
3299
+ <line number="320" hits="11" branch="false"/>
3300
+ <line number="321" hits="0" branch="false"/>
3301
+ <line number="323" hits="0" branch="false"/>
3302
+ <line number="324" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3303
+ <line number="326" hits="0" branch="false"/>
3304
+ <line number="327" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3305
+ <line number="332" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3306
+ <line number="333" hits="0" branch="false"/>
3307
+ <line number="335" hits="0" branch="false"/>
3308
+ <line number="338" hits="0" branch="false"/>
3309
+ <line number="349" hits="0" branch="false"/>
3310
+ <line number="358" hits="0" branch="false"/>
3311
+ <line number="360" hits="0" branch="false"/>
3312
+ <line number="372" hits="11" branch="false"/>
3313
+ <line number="373" hits="1" branch="false"/>
3314
+ <line number="376" hits="0" branch="false"/>
3315
+ <line number="377" hits="0" branch="false"/>
3316
+ <line number="380" hits="0" branch="false"/>
3317
+ <line number="385" hits="1" branch="false"/>
3318
+ <line number="386" hits="21" branch="false"/>
3319
+ <line number="387" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3320
+ <line number="393" hits="2" branch="false"/>
3321
+ <line number="397" hits="0" branch="false"/>
3322
+ <line number="398" hits="0" branch="false"/>
3323
+ <line number="399" hits="0" branch="true" condition-coverage="0% (0/2)"/>
3324
+ <line number="404" hits="2" branch="false"/>
3325
+ <line number="405" hits="0" branch="false"/>
3326
+ <line number="406" hits="0" branch="false"/>
3327
+ <line number="410" hits="0" branch="true" condition-coverage="0% (0/4)"/>
3328
+ <line number="414" hits="0" branch="true" condition-coverage="0% (0/3)"/>
3329
+ <line number="415" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3330
+ <line number="416" hits="0" branch="false"/>
3314
3331
  <line number="419" hits="0" branch="false"/>
3315
- <line number="423" hits="11" branch="false"/>
3316
- <line number="424" hits="22" branch="true" condition-coverage="100% (2/2)"/>
3317
- <line number="425" hits="1" branch="true" condition-coverage="100% (2/2)"/>
3332
+ <line number="422" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3333
+ <line number="423" hits="0" branch="false"/>
3334
+ <line number="426" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3335
+ <line number="427" hits="0" branch="false"/>
3336
+ <line number="432" hits="2" branch="false"/>
3337
+ <line number="435" hits="0" branch="false"/>
3338
+ <line number="436" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3339
+ <line number="437" hits="0" branch="false"/>
3340
+ <line number="441" hits="0" branch="true" condition-coverage="0% (0/1)"/>
3341
+ <line number="443" hits="0" branch="false"/>
3342
+ <line number="447" hits="11" branch="false"/>
3343
+ <line number="448" hits="22" branch="true" condition-coverage="100% (2/2)"/>
3344
+ <line number="449" hits="1" branch="true" condition-coverage="100% (2/2)"/>
3318
3345
  </lines>
3319
3346
  </class>
3320
3347
  <class name="deviceSetup.ts" filename="src/Device/deviceSetup.ts" line-rate="0.6890999999999999" branch-rate="0.4375">
@@ -4874,10 +4901,10 @@
4874
4901
  <line number="92" hits="6" branch="false"/>
4875
4902
  <line number="93" hits="6" branch="false"/>
4876
4903
  <line number="94" hits="6" branch="false"/>
4877
- <line number="95" hits="6" branch="false"/>
4878
- <line number="97" hits="6" branch="true" condition-coverage="75% (3/4)"/>
4904
+ <line number="96" hits="6" branch="true" condition-coverage="75% (3/4)"/>
4905
+ <line number="97" hits="6" branch="false"/>
4879
4906
  <line number="98" hits="6" branch="false"/>
4880
- <line number="99" hits="6" branch="false"/>
4907
+ <line number="104" hits="6" branch="false"/>
4881
4908
  <line number="105" hits="6" branch="false"/>
4882
4909
  <line number="106" hits="6" branch="false"/>
4883
4910
  <line number="108" hits="6" branch="false"/>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nordicsemiconductor/pc-nrfconnect-shared",
3
- "version": "129.0.0",
3
+ "version": "131.0.0",
4
4
  "description": "Shared commodities for developing pc-nrfconnect-* packages",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,6 +43,7 @@ const bundle = () => {
43
43
  build({
44
44
  define: {
45
45
  'process.env.PACKAGE_JSON': JSON.stringify(packageJson),
46
+ 'process.env.APPLICATIONINSIGHTS_CONFIGURATION_CONTENT': '"{}"', // Needed because of https://github.com/microsoft/ApplicationInsights-node.js/issues/1226
46
47
  },
47
48
  entryPoints: [entry()],
48
49
  });
@@ -92,7 +92,6 @@ export default ({
92
92
  setDeviceListVisible(false);
93
93
  dispatch(selectDevice(device));
94
94
  dispatch(setAutoSelectDevice(device));
95
- onDeviceSelected(device, autoReselected);
96
95
 
97
96
  abortController.current?.abort();
98
97
  abortController.current = new AbortController();
@@ -104,6 +103,7 @@ export default ({
104
103
  );
105
104
  abortController.current = undefined;
106
105
  setSelectedDeviceInfo(deviceInfo);
106
+ onDeviceSelected(device, autoReselected);
107
107
 
108
108
  usageData.sendUsageData('device selected', {
109
109
  device: simplifyDeviceForLogging(device),
@@ -163,135 +163,159 @@ export const startWatchingDevices =
163
163
  doSelectDevice: (device: Device, autoReselected: boolean) => void
164
164
  ): AppThunk<RootState, void> =>
165
165
  (dispatch, getState) => {
166
- const onDeviceArrived = async (device: NrfutilDevice) => {
167
- if (hasValidDeviceTraits(device.traits, deviceListing)) {
168
- usageData.sendUsageData(
169
- 'device connected',
170
- simplifyDeviceForLogging(device)
171
- );
172
- if (
173
- !getState().device.devices.find(
174
- d =>
175
- d.id === device.id ||
176
- (device.serialNumber && // we want to disregard comparing devices with no sn
177
- d.serialNumber === device.serialNumber)
178
- )
179
- ) {
180
- onDeviceConnected(device);
181
- }
182
-
183
- const disconnectionTime =
184
- getState().deviceAutoSelect.disconnectionTime;
185
- const autoSelectDevice = getState().deviceAutoSelect.device;
186
- const selectedDevice = getState().device.selectedDevice;
187
-
188
- const result = shouldAutoReselect(
189
- device,
190
- getState().deviceAutoSelect.autoReselect,
191
- autoSelectDevice,
192
- disconnectionTime,
193
- selectedDevice
194
- );
195
-
196
- dispatch(addDevice(device));
197
- const deviceWithPersistedData = getState().device.devices.find(
198
- d => d.serialNumber === device.serialNumber
199
- );
200
-
201
- if (!deviceWithPersistedData) return;
202
-
203
- // We might get multiple events with the same info so no to trigger auto reconnect multiple times we
204
- // only do it once per device id
205
- if (
206
- result &&
207
- getState().deviceAutoSelect.lastArrivedDeviceId !==
208
- deviceWithPersistedData.id
209
- ) {
210
- dispatch(
211
- setLastArrivedDeviceId(deviceWithPersistedData.id)
212
- );
166
+ const deviceToProcess: Device[] = [];
167
+ const onDeviceArrived = (dev: NrfutilDevice) => {
168
+ deviceToProcess.push(dev);
169
+ if (deviceToProcess.length > 1) {
170
+ return;
171
+ }
213
172
 
214
- const deviceInfo = await NrfutilDeviceLib.deviceInfo(
215
- device
173
+ const action = async (device: Device) => {
174
+ if (hasValidDeviceTraits(device.traits, deviceListing)) {
175
+ usageData.sendUsageData(
176
+ 'device connected',
177
+ simplifyDeviceForLogging(device)
216
178
  );
179
+ if (
180
+ !getState().device.devices.find(
181
+ d =>
182
+ d.id === device.id ||
183
+ (device.serialNumber && // we want to disregard comparing devices with no sn
184
+ d.serialNumber === device.serialNumber)
185
+ )
186
+ ) {
187
+ onDeviceConnected(device);
188
+ }
217
189
 
218
- logger.info(
219
- `Auto Reconnecting Device SN: ${deviceWithPersistedData.serialNumber}`
190
+ const disconnectionTime =
191
+ getState().deviceAutoSelect.disconnectionTime;
192
+ const autoSelectDevice = getState().deviceAutoSelect.device;
193
+ const selectedDevice = getState().device.selectedDevice;
194
+
195
+ const result = shouldAutoReselect(
196
+ device,
197
+ getState().deviceAutoSelect.autoReselect,
198
+ autoSelectDevice,
199
+ disconnectionTime,
200
+ selectedDevice
220
201
  );
221
- doSelectDevice(deviceWithPersistedData, true);
222
- dispatch(setSelectedDeviceInfo(deviceInfo));
223
- } else if (
224
- deviceWithPersistedData.serialNumber ===
225
- getState().deviceAutoSelect.device?.serialNumber
226
- ) {
227
- const waitForDevice =
228
- getState().deviceAutoSelect.waitForDevice;
229
202
 
230
- const deviceInfo = await NrfutilDeviceLib.deviceInfo(
231
- device
232
- );
203
+ dispatch(addDevice(device));
204
+ const deviceWithPersistedData =
205
+ getState().device.devices.find(
206
+ d => d.serialNumber === device.serialNumber
207
+ );
233
208
 
234
- // Device lib might fail to advertise that a device has left before it rejoins (Mainly OSx)
235
- // but we still need to trigger the onSuccess if a device 'reappeared' with a different 'id'
236
- // and there is an outstanding waitForDevice Request. In this case the disconnectionTime was
237
- // never set (as NRFDL_DEVICE_EVENT_LEFT was never sent) This created an additional problem as device
238
- // lib may advertise the the same device with a single connect event. Hance we are keeping track of
239
- // the device ID which is guaranteed to be change if a is disconnected and reconnected (for the
240
- // same hotplug event listener) to ensure we only call the onSuccess once for every reconnect event.
241
- // This is mostly relevant when 'when' is always
209
+ if (!deviceWithPersistedData) return;
242
210
 
243
- // Device is to be reconnected as timeout is provided
211
+ // We might get multiple events with the same info so no to trigger auto reconnect multiple times we
212
+ // only do it once per device id
244
213
  if (
245
- waitForDevice &&
246
- ((disconnectionTime === undefined &&
247
- getState().deviceAutoSelect.lastArrivedDeviceId !==
248
- deviceWithPersistedData.id) ||
249
- (disconnectionTime ?? 0) + waitForDevice.timeout >=
250
- Date.now())
214
+ result &&
215
+ getState().deviceAutoSelect.lastArrivedDeviceId !==
216
+ deviceWithPersistedData.id
251
217
  ) {
218
+ dispatch(
219
+ setLastArrivedDeviceId(deviceWithPersistedData.id)
220
+ );
221
+
222
+ const deviceInfo = await NrfutilDeviceLib.deviceInfo(
223
+ device
224
+ );
225
+
226
+ logger.info(
227
+ `Auto Reconnecting Device SN: ${deviceWithPersistedData.serialNumber}`
228
+ );
229
+ doSelectDevice(deviceWithPersistedData, true);
230
+ dispatch(setSelectedDeviceInfo(deviceInfo));
231
+ } else if (
232
+ deviceWithPersistedData.serialNumber ===
233
+ getState().deviceAutoSelect.device?.serialNumber
234
+ ) {
235
+ const waitForDevice =
236
+ getState().deviceAutoSelect.waitForDevice;
237
+
238
+ const deviceInfo = await NrfutilDeviceLib.deviceInfo(
239
+ device
240
+ );
241
+
242
+ // Device lib might fail to advertise that a device has left before it rejoins (Mainly OSx)
243
+ // but we still need to trigger the onSuccess if a device 'reappeared' with a different 'id'
244
+ // and there is an outstanding waitForDevice Request. In this case the disconnectionTime was
245
+ // never set (as NRFDL_DEVICE_EVENT_LEFT was never sent) This created an additional problem as device
246
+ // lib may advertise the the same device with a single connect event. Hance we are keeping track of
247
+ // the device ID which is guaranteed to be change if a is disconnected and reconnected (for the
248
+ // same hotplug event listener) to ensure we only call the onSuccess once for every reconnect event.
249
+ // This is mostly relevant when 'when' is always
250
+
251
+ // Device is to be reconnected as timeout is provided
252
252
  if (
253
- waitForDevice.when === 'always' ||
254
- (waitForDevice.when === 'dfuBootLoaderMode' &&
255
- isDeviceInDFUBootloader(
256
- deviceWithPersistedData
257
- )) ||
258
- (waitForDevice.when === 'applicationMode' &&
259
- deviceInfo?.dfuTriggerVersion) ||
260
- (selectedDevice &&
261
- waitForDevice.when === 'sameTraits' &&
262
- hasSameDeviceTraits(
263
- device.traits,
264
- selectedDevice.traits
265
- )) ||
266
- (typeof waitForDevice.when === 'function' &&
267
- waitForDevice.when(device))
253
+ waitForDevice &&
254
+ ((disconnectionTime === undefined &&
255
+ getState().deviceAutoSelect
256
+ .lastArrivedDeviceId !==
257
+ deviceWithPersistedData.id) ||
258
+ (disconnectionTime ?? 0) +
259
+ waitForDevice.timeout >=
260
+ Date.now())
268
261
  ) {
269
- dispatch(
270
- setLastArrivedDeviceId(
271
- deviceWithPersistedData.id
272
- )
273
- );
274
- dispatch(setDisconnectedTime(undefined));
262
+ if (
263
+ waitForDevice.when === 'always' ||
264
+ (waitForDevice.when === 'dfuBootLoaderMode' &&
265
+ isDeviceInDFUBootloader(
266
+ deviceWithPersistedData
267
+ )) ||
268
+ (waitForDevice.when === 'applicationMode' &&
269
+ deviceInfo?.dfuTriggerVersion) ||
270
+ (selectedDevice &&
271
+ waitForDevice.when === 'sameTraits' &&
272
+ hasSameDeviceTraits(
273
+ device.traits,
274
+ selectedDevice.traits
275
+ )) ||
276
+ (typeof waitForDevice.when === 'function' &&
277
+ waitForDevice.when(device))
278
+ ) {
279
+ dispatch(
280
+ setLastArrivedDeviceId(
281
+ deviceWithPersistedData.id
282
+ )
283
+ );
284
+ dispatch(setDisconnectedTime(undefined));
275
285
 
276
- logger.info('Wait For Device was successfully');
286
+ logger.info('Wait For Device was successfully');
277
287
 
278
- dispatch(
279
- clearWaitForDeviceTimeout(waitForDevice.once)
280
- );
288
+ dispatch(
289
+ clearWaitForDeviceTimeout(
290
+ waitForDevice.once
291
+ )
292
+ );
281
293
 
282
- dispatch(selectDevice(deviceWithPersistedData));
283
- dispatch(setSelectedDeviceInfo(deviceInfo));
294
+ dispatch(selectDevice(deviceWithPersistedData));
295
+ dispatch(setSelectedDeviceInfo(deviceInfo));
284
296
 
285
- if (waitForDevice.onSuccess)
286
- waitForDevice.onSuccess(
287
- deviceWithPersistedData
288
- );
289
- } else {
290
- dispatch(setArrivedButWrongWhen(true));
297
+ if (waitForDevice.onSuccess)
298
+ waitForDevice.onSuccess(
299
+ deviceWithPersistedData
300
+ );
301
+ } else {
302
+ dispatch(setArrivedButWrongWhen(true));
303
+ }
291
304
  }
292
305
  }
293
306
  }
294
- }
307
+ };
308
+
309
+ const rec = (p: Promise<void>) => {
310
+ p.finally(() => {
311
+ deviceToProcess.splice(0, 1); // remove completed devices
312
+ const d = deviceToProcess[0];
313
+ if (!d) return;
314
+ rec(action(d));
315
+ });
316
+ };
317
+
318
+ rec(action(deviceToProcess[0]));
295
319
  };
296
320
  const onDeviceLeft = (id: number) => {
297
321
  const devices = getState().device.devices;
@@ -29,7 +29,7 @@ export interface TerminalSettings {
29
29
 
30
30
  const sharedStore = new Store<{
31
31
  verboseLogging: boolean;
32
- isSendingUsageData: boolean | undefined;
32
+ isSendingTelemetry: boolean | undefined;
33
33
  clientId?: string;
34
34
  }>({
35
35
  name: 'pc-nrfconnect-shared',
@@ -117,11 +117,11 @@ export const getPersistedTerminalSettings = (
117
117
  };
118
118
 
119
119
  export const persistIsSendingUsageData = (value: boolean) =>
120
- sharedStore.set('isSendingUsageData', value);
120
+ sharedStore.set('isSendingTelemetry', value);
121
121
  export const getIsSendingUsageData = () =>
122
- sharedStore.get('isSendingUsageData', undefined) as boolean | undefined;
122
+ sharedStore.get('isSendingTelemetry', undefined) as boolean | undefined;
123
123
  export const deleteIsSendingUsageData = () =>
124
- sharedStore.delete('isSendingUsageData');
124
+ sharedStore.delete('isSendingTelemetry');
125
125
 
126
126
  const existingUsageDataClientId = () => sharedStore.get('clientId');
127
127
  const newUsageDataClientId = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"deviceLister.d.ts","sourceRoot":"","sources":["../../../../src/Device/deviceLister.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAiB,MAAM,6BAA6B,CAAC;AAG1E,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAcpD,OAAO,EAEH,MAAM,EAIT,MAAM,eAAe,CAAC;AAkFvB,eAAO,MAAM,oBAAoB,iBACf,YAAY,kBACV,YAAY,YAS3B,CAAC;AAkCN,eAAO,MAAM,oBAAoB,kBAEV,YAAY,8BACC,MAAM,KAAK,IAAI,iCACZ,MAAM,KAAK,IAAI,sBAC1B,MAAM,IAAI,2BACL,MAAM,kBAAkB,OAAO,KAAK,IAAI,KAClE,SAAS,SAAS,EAAE,IAAI,CA2M1B,CAAC;AAwDN,eAAO,MAAM,mBAAmB,cAAe,MAAM,IAAI,SAGxD,CAAC"}
1
+ {"version":3,"file":"deviceLister.d.ts","sourceRoot":"","sources":["../../../../src/Device/deviceLister.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,YAAY,EAAiB,MAAM,6BAA6B,CAAC;AAG1E,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAcpD,OAAO,EAEH,MAAM,EAIT,MAAM,eAAe,CAAC;AAkFvB,eAAO,MAAM,oBAAoB,iBACf,YAAY,kBACV,YAAY,YAS3B,CAAC;AAkCN,eAAO,MAAM,oBAAoB,kBAEV,YAAY,8BACC,MAAM,KAAK,IAAI,iCACZ,MAAM,KAAK,IAAI,sBAC1B,MAAM,IAAI,2BACL,MAAM,kBAAkB,OAAO,KAAK,IAAI,KAClE,SAAS,SAAS,EAAE,IAAI,CAmO1B,CAAC;AAwDN,eAAO,MAAM,mBAAmB,cAAe,MAAM,IAAI,SAGxD,CAAC"}