Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Jul 26, 2024
1 parent 851d12e commit 827ada4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dfu.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,16 @@ class Dfu {
*/
async getProtectionState() {
try {
const res = await this._getStringDescriptor(0xfe);
const state = res.split(';').find(kv => kv.startsWith('sm='))?.split('=')[1];

const res = await this._getStringDescriptor(0xfa);
const state = res.split(';').find(kv => kv.startsWith('sm='))?.split('=')[1]?.trim().charAt(0);
switch (state) {
case 'o': return { protected: false, overridden: false };
case 'p': return { protected: true };
case 's': return { protected: false, overridden: true };
default: throw new Error('Unknown device state');
}
} catch (error) {
console.warn('Failed to get protection state', error);
// Fallback for devices with Device-OS < 6.1.2
await this.setAltSetting(0); // setting 0 is for Internal Flash

Expand Down

0 comments on commit 827ada4

Please sign in to comment.