feat: edit value & send to brew
- edited value is now sent to brew Signed-off-by: pakintada@gmail.com <Pakin>
This commit is contained in:
parent
dc327e7779
commit
4cb98f8672
7 changed files with 141 additions and 4 deletions
|
|
@ -223,11 +223,20 @@ async function connectToAndroidServer() {
|
|||
console.warn('adb instance not found');
|
||||
return;
|
||||
}
|
||||
|
||||
await push('/sdcard/coffeevending/enable_adb_block_watch', '1');
|
||||
|
||||
const stream = await inst.transport.connect(env.PUBLIC_BREW_CONN_PORT);
|
||||
const writer = stream.writable.getWriter();
|
||||
const reader = stream.readable.getReader();
|
||||
|
||||
console.log('checking on writer ', writer);
|
||||
adbWriter.set(writer);
|
||||
if (writer) {
|
||||
addNotification('INFO:Enable Brewing Mode T on machine');
|
||||
} else {
|
||||
addNotification('WARN:Brewing Mode T unavailable');
|
||||
}
|
||||
|
||||
(async () => {
|
||||
try {
|
||||
|
|
@ -240,10 +249,12 @@ async function connectToAndroidServer() {
|
|||
console.error('read error', e);
|
||||
} finally {
|
||||
adbWriter.set(null);
|
||||
addNotification('WARN:Brewing Mode T Offline ...');
|
||||
}
|
||||
})();
|
||||
} catch (err) {
|
||||
console.error('Connection failed. Suspect java running or not', err);
|
||||
addNotification('ERR:Fail to enable brewing mode T');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ async function handleAdbPayload(raw_payload: string) {
|
|||
let next = states[1].replace('MACHINE_STATE_', '');
|
||||
|
||||
console.log('current state', curr, 'next state', next);
|
||||
|
||||
addNotification('INFO:Machine Status Updated, ' + next);
|
||||
}
|
||||
break;
|
||||
case 'error':
|
||||
|
|
|
|||
|
|
@ -51,6 +51,11 @@ export function sendMessage(msg: OutMessage): boolean {
|
|||
console.warn('WebSocket not connected, put to queue');
|
||||
|
||||
let currentQueue = get(queue);
|
||||
if (currentQueue.length >= 10) {
|
||||
while (currentQueue.length >= 10) {
|
||||
currentQueue.shift();
|
||||
}
|
||||
}
|
||||
currentQueue.push(data);
|
||||
queue.set(currentQueue);
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ async function sendToAndroid(message: any) {
|
|||
const encoder = new TextEncoder();
|
||||
console.log(writer);
|
||||
await writer.write(encoder.encode(JSON.stringify(message) + '\n'));
|
||||
console.log('sent!');
|
||||
console.log('sent! ', JSON.stringify(message));
|
||||
} catch (error) {
|
||||
console.error('write failed', error);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue