Skip to content

Commit

Permalink
Fix entering bootloaders using flow control.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerivec committed Nov 4, 2024
1 parent 5054160 commit e442dea
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '20'
node-version-file: 'package.json'

- run: npm install -g oclif

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ $ npm install -g ember-zli
$ ember-zli COMMAND
running command...
$ ember-zli (--version)
ember-zli/2.7.0 win32-x64 node-v22.11.0
ember-zli/2.8.0 win32-x64 node-v22.11.0
$ ember-zli --help [COMMAND]
USAGE
$ ember-zli COMMAND
Expand Down Expand Up @@ -108,7 +108,7 @@ EXAMPLES
$ ember-zli bootloader
```

_See code: [src/commands/bootloader/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.7.0/src/commands/bootloader/index.ts)_
_See code: [src/commands/bootloader/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.8.0/src/commands/bootloader/index.ts)_

## `ember-zli help [COMMAND]`

Expand Down Expand Up @@ -145,7 +145,7 @@ EXAMPLES
$ ember-zli router
```

_See code: [src/commands/router/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.7.0/src/commands/router/index.ts)_
_See code: [src/commands/router/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.8.0/src/commands/router/index.ts)_

## `ember-zli sniff`

Expand All @@ -162,7 +162,7 @@ EXAMPLES
$ ember-zli sniff
```

_See code: [src/commands/sniff/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.7.0/src/commands/sniff/index.ts)_
_See code: [src/commands/sniff/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.8.0/src/commands/sniff/index.ts)_

## `ember-zli stack`

Expand All @@ -179,7 +179,7 @@ EXAMPLES
$ ember-zli stack
```

_See code: [src/commands/stack/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.7.0/src/commands/stack/index.ts)_
_See code: [src/commands/stack/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.8.0/src/commands/stack/index.ts)_

## `ember-zli utils`

Expand All @@ -196,7 +196,7 @@ EXAMPLES
$ ember-zli utils
```

_See code: [src/commands/utils/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.7.0/src/commands/utils/index.ts)_
_See code: [src/commands/utils/index.ts](https://github.com/Nerivec/ember-zli/blob/v2.8.0/src/commands/utils/index.ts)_

## `ember-zli version`

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ember-zli",
"description": "Interact with EmberZNet-based adapters using zigbee-herdsman 'ember' driver",
"version": "2.7.0",
"version": "2.8.0",
"author": "Nerivec",
"bin": {
"ember-zli": "bin/run.js"
Expand Down Expand Up @@ -37,7 +37,7 @@
"typescript-eslint": "^8"
},
"engines": {
"node": ">=20.0.0"
"node": ">=20.15.0"
},
"files": [
"/bin",
Expand Down
15 changes: 12 additions & 3 deletions src/utils/bootloader.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { AdapterModel, FirmwareFileMetadata, PortConf } from './types.js'

import EventEmitter from 'node:events'
import { crc32 } from 'zlib'

import { confirm } from '@inquirer/prompts'
import {crc32} from 'zlib'

import { SLStatus } from 'zigbee-herdsman/dist/adapter/ember/enums.js'

Expand Down Expand Up @@ -394,9 +394,18 @@ export class GeckoBootloader extends EventEmitter<GeckoBootloaderEventMap> {
return
}

await this.transport.write(BOOTLOADER_KNOCK)
let res: boolean = false

const res = await this.waitForState(BootloaderState.IDLE, BOOTLOADER_KNOCK_TIMEOUT, fail)
for (let i = 1; i < 3; i++) {
await this.transport.write(BOOTLOADER_KNOCK)

res = await this.waitForState(BootloaderState.IDLE, BOOTLOADER_KNOCK_TIMEOUT, fail && i == 2)

if (!res && i == 1 && this.transport.isSerial) {
// if failed first attempt, try second time with RTS/CTS enabled
await this.transport.serialSet({ rts: true, cts: true })
}
}

if (!res) {
await this.transport.close(fail) // emit closed based on if we want to fail on unsuccessful knock
Expand Down

0 comments on commit e442dea

Please sign in to comment.