diff --git a/src/DataProcessor.ts b/src/DataProcessor.ts index 5cfad626e..ced392ca6 100644 --- a/src/DataProcessor.ts +++ b/src/DataProcessor.ts @@ -152,7 +152,7 @@ export class DataProcessor { } } this.logger.debug( - `Device ${clientId}` + + `Device ${clientId} ` + `wsman response ${statusCode} ${resolveValue ? 'resolved' : 'rejected'}: ` + `${JSON.stringify(clientMsg.payload, null, '\t')}` ) diff --git a/src/stateMachines/activation.ts b/src/stateMachines/activation.ts index b8bb7bbda..cf51e6247 100644 --- a/src/stateMachines/activation.ts +++ b/src/stateMachines/activation.ts @@ -877,7 +877,7 @@ export class Activation { 'Set activation status' ], - target: 'UPDATE_CREDENTIALS' + target: 'DELAYED_TRANSITION' }, { guard: 'isDeviceClientModeActivated', diff --git a/src/stateMachines/deactivation.ts b/src/stateMachines/deactivation.ts index f0824fb0c..94c0595ae 100644 --- a/src/stateMachines/deactivation.ts +++ b/src/stateMachines/deactivation.ts @@ -109,7 +109,7 @@ export class Deactivation { unauthCount: 0, xmlMessage: input.xmlMessage, errorMessage: input.errorMessage, - statusMessage: input.statusMessage, + statusMessage: '', tenantId: input.tenantId, httpHandler: new HttpHandler() }), diff --git a/src/stateMachines/error.ts b/src/stateMachines/error.ts index d3082cb53..e56243605 100644 --- a/src/stateMachines/error.ts +++ b/src/stateMachines/error.ts @@ -7,6 +7,7 @@ import { sendParent, setup } from 'xstate' import { HttpHandler } from '../HttpHandler.js' import { devices } from '../devices.js' import { type HttpZResponseModel } from 'http-z' +import Logger from '../Logger.js' const httpHandler = new HttpHandler() export interface ErrorContext { @@ -20,6 +21,8 @@ interface ErrorEvent { } export class Error { + logger: Logger + addAuthorizationHeader = ({ context }: { context: ErrorContext }): void => { const { message, clientId } = context const clientObj = devices[clientId] @@ -38,6 +41,7 @@ export class Error { resetAuthCount = ({ context }: { context: ErrorContext }): void => { if (devices[context.clientId] != null) { devices[context.clientId].unauthCount = 0 + this.logger.silly(`Reset unauthCount of ${context.clientId} to 0`) } } @@ -70,7 +74,10 @@ export class Error { resetAuthCount: this.resetAuthCount } }).createMachine({ - context: ({ input }) => ({ message: input.message, clientId: input.clientId }), + context: ({ input }) => { + this.logger.silly(`${JSON.stringify(input.message)}`) + return { message: input.message, clientId: input.clientId } + }, id: 'error-machine', initial: 'ERRORED', states: { @@ -117,4 +124,8 @@ export class Error { } } }) + + constructor() { + this.logger = new Logger('Error_State_Machine') + } } diff --git a/src/stateMachines/unconfiguration.ts b/src/stateMachines/unconfiguration.ts index 86d407dee..f4dd6ada5 100644 --- a/src/stateMachines/unconfiguration.ts +++ b/src/stateMachines/unconfiguration.ts @@ -510,7 +510,7 @@ export class Unconfiguration { src: 'errorMachine', id: 'error-machine', input: ({ context, event }) => ({ - message: event.output, + message: event.error, clientId: context.clientId }), onDone: 'ENUMERATE_ETHERNET_PORT_SETTINGS' @@ -1086,6 +1086,6 @@ export class Unconfiguration { this.configurator = new Configurator() this.validator = new Validator(new Logger('Validator'), this.configurator) this.dbFactory = new DbCreatorFactory() - this.logger = new Logger('Activation_State_Machine') + this.logger = new Logger('Unconfiguration_State_Machine') } }