fix(k1): translate onboard operation identities at plugin boundary
This commit is contained in:
@@ -45,6 +45,7 @@ export interface EnrollmentObserver {
|
||||
pause?:()=>Promise<void>;
|
||||
}
|
||||
const unknownResult='Результат подключения пока не подтверждён. Обновите состояние K1 перед новой попыткой.';
|
||||
const scanFailure='Не удалось выполнить поиск Bluetooth на БК. Проверьте Bluetooth на бортовом компьютере и повторите поиск.';
|
||||
|
||||
/** Submit once. HTTP delivery and the device's network/control result are separate. */
|
||||
export async function enroll(transport:EnrollmentTransport,initial:EnrollmentState,action:EnrollmentCommand['action'],parameters:Record<string,unknown>={},observer:EnrollmentObserver={}):Promise<EnrollmentState>{
|
||||
@@ -76,6 +77,9 @@ export async function enroll(transport:EnrollmentTransport,initial:EnrollmentSta
|
||||
try{operation=await transport.operation(command.operation_id);}catch{operation=null;}
|
||||
}
|
||||
if(action==='scan'||action==='networks'){
|
||||
if(action==='scan'&&(operation.state!=='complete'||!operation.result||
|
||||
(state.command_result?.operation_id===command.operation_id&&state.command_result.status!=='succeeded')))
|
||||
throw new Error(scanFailure);
|
||||
if(operation.state!=='complete'||!operation.result)throw new Error(operation.error||unknownResult);
|
||||
return state;
|
||||
}
|
||||
@@ -106,6 +110,7 @@ export async function enroll(transport:EnrollmentTransport,initial:EnrollmentSta
|
||||
export function enrollmentNotice(state:EnrollmentState):string {
|
||||
const attempt=connectionAttempt(state);
|
||||
if(!state.available||state.fresh===false)return 'Нет свежих сведений с БК. Восстанавливаем связь.';
|
||||
if(state.command_result?.action==='scan')return ''; // Scan failures belong to the search toast, not a Wi-Fi notice.
|
||||
if(attempt?.status==='accepted'||attempt?.status==='running'){
|
||||
return attempt.phase==='network_applied'?'K1 подключился к Wi-Fi. Проверяем канал управления.':'Подключаем K1 к выбранной сети Wi-Fi.';
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ from credential_install import PROFILE_ID, validate # noqa: E402
|
||||
from debian import package # noqa: E402
|
||||
from runtime_payload import files as runtime_files # noqa: E402
|
||||
|
||||
VERSION = "0.1.1"
|
||||
VERSION = "0.1.2"
|
||||
RESOURCES = (
|
||||
"plugins/xgrids-k1/profile_loader.py",
|
||||
"plugins/xgrids-k1/plugin.manifest.json",
|
||||
|
||||
Reference in New Issue
Block a user