From 76a5f8fe26ca3f82c78bc6754af03da9863ce7e2 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 6 Apr 2021 13:42:26 -0500 Subject: [PATCH 1/3] drop HubRuntimeStatusType Idle and Running These are no longer used --- src/hub/actions.ts | 2 -- src/hub/reducers.ts | 4 ---- 2 files changed, 6 deletions(-) diff --git a/src/hub/actions.ts b/src/hub/actions.ts index f7acc397..a816662e 100644 --- a/src/hub/actions.ts +++ b/src/hub/actions.ts @@ -4,10 +4,8 @@ import { Action } from 'redux'; export enum HubRuntimeStatusType { - Idle = 'idle', Loading = 'loading', Loaded = 'loaded', - Running = 'running', Error = 'error', } diff --git a/src/hub/reducers.ts b/src/hub/reducers.ts index 3fe4fb66..392114a6 100644 --- a/src/hub/reducers.ts +++ b/src/hub/reducers.ts @@ -51,14 +51,10 @@ const runtime: Reducer = ( return HubRuntimeState.Disconnected; case HubMessageActionType.RuntimeStatus: switch (action.newStatus) { - case HubRuntimeStatusType.Idle: - return HubRuntimeState.Idle; case HubRuntimeStatusType.Loading: return HubRuntimeState.Loading; case HubRuntimeStatusType.Loaded: return HubRuntimeState.Loaded; - case HubRuntimeStatusType.Running: - return HubRuntimeState.Running; case HubRuntimeStatusType.Error: return HubRuntimeState.Error; default: From 605a9107468cbb9013840b7c35c042f94b402b4f Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 6 Apr 2021 13:48:38 -0500 Subject: [PATCH 2/3] Fix failing download and run The firmware was changed to send status updates at a regular interval which caused the hub state to change back to idle prematurely during download and run. This caused any program more than one or two lines long to fail. Issue: https://github.com/pybricks/support/issues/290 --- src/hub/reducers.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/hub/reducers.ts b/src/hub/reducers.ts index 392114a6..ea66cbc4 100644 --- a/src/hub/reducers.ts +++ b/src/hub/reducers.ts @@ -62,9 +62,16 @@ const runtime: Reducer = ( return state; } case BlePybricksServiceEventActionType.StatusReport: - return action.statusFlags & statusToFlag(Status.UserProgramRunning) - ? HubRuntimeState.Running - : HubRuntimeState.Idle; + if (action.statusFlags & statusToFlag(Status.UserProgramRunning)) { + return HubRuntimeState.Running; + } + // TODO: Status report flags should probably separated from hub runtime state. + // For now, we have this hack to ensure status updates don't interfere with + // download and run + if (state !== HubRuntimeState.Loading && state !== HubRuntimeState.Loaded) { + return HubRuntimeState.Idle; + } + return state; default: return state; } From 845645093461006061c4125d2c19bcd072ffa996 Mon Sep 17 00:00:00 2001 From: David Lechner Date: Tue, 6 Apr 2021 13:50:59 -0500 Subject: [PATCH 3/3] v1.0.0-beta.10 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d8e4b8fb..945f4f8e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pybricks/pybricks-code", - "version": "1.0.0-beta.9", + "version": "1.0.0-beta.10", "license": "MIT", "author": "The Pybricks Authors", "repository": {