Browse Source

Start debug log

pull/21/head
Sacha Weatherstone 4 years ago
parent
commit
10be79267e
  1. 2
      package.json
  2. 8
      pnpm-lock.yaml
  3. 17
      src/components/Connection.tsx
  4. 5
      src/core/connection.ts
  5. 6
      src/core/slices/meshtasticSlice.ts

2
package.json

@ -15,7 +15,7 @@
"@emeraldpay/hashicon-react": "^0.5.2", "@emeraldpay/hashicon-react": "^0.5.2",
"@floating-ui/react-dom": "^0.4.3", "@floating-ui/react-dom": "^0.4.3",
"@meshtastic/components": "^1.0.23", "@meshtastic/components": "^1.0.23",
"@meshtastic/meshtasticjs": "^0.6.39", "@meshtastic/meshtasticjs": "^0.6.42",
"@reduxjs/toolkit": "^1.7.2", "@reduxjs/toolkit": "^1.7.2",
"base64-js": "^1.5.1", "base64-js": "^1.5.1",
"framer-motion": "^6.2.6", "framer-motion": "^6.2.6",

8
pnpm-lock.yaml

@ -4,7 +4,7 @@ specifiers:
'@emeraldpay/hashicon-react': ^0.5.2 '@emeraldpay/hashicon-react': ^0.5.2
'@floating-ui/react-dom': ^0.4.3 '@floating-ui/react-dom': ^0.4.3
'@meshtastic/components': ^1.0.23 '@meshtastic/components': ^1.0.23
'@meshtastic/meshtasticjs': ^0.6.39 '@meshtastic/meshtasticjs': ^0.6.42
'@reduxjs/toolkit': ^1.7.2 '@reduxjs/toolkit': ^1.7.2
'@types/mapbox-gl': ^2.6.1 '@types/mapbox-gl': ^2.6.1
'@types/react': ^17.0.39 '@types/react': ^17.0.39
@ -62,7 +62,7 @@ dependencies:
'@emeraldpay/hashicon-react': 0.5.2 '@emeraldpay/hashicon-react': 0.5.2
'@floating-ui/react-dom': 0.4.3_b8fdba992ce7d797017dc07106486496 '@floating-ui/react-dom': 0.4.3_b8fdba992ce7d797017dc07106486496
'@meshtastic/components': 1.0.23_@[email protected] '@meshtastic/components': 1.0.23_@[email protected]
'@meshtastic/meshtasticjs': 0.6.39 '@meshtastic/meshtasticjs': 0.6.42
'@reduxjs/toolkit': 1.7[email protected][email protected] '@reduxjs/toolkit': 1.7[email protected][email protected]
base64-js: 1.5.1 base64-js: 1.5.1
framer-motion: 6.2[email protected][email protected] framer-motion: 6.2[email protected][email protected]
@ -1587,8 +1587,8 @@ packages:
- '@types/react' - '@types/react'
dev: false dev: false
/@meshtastic/meshtasticjs/0.6.39: /@meshtastic/meshtasticjs/0.6.42:
resolution: {integrity: sha512-L2m+0erT2niz2UhPPa8LI3bt3/WdISilzHgMF2Akz5VmkUrllxFfug/ITQuxifQfApl3xoo7TA1LQdBF1xy1oA==} resolution: {integrity: sha512-sZLsOZXyrMUIVk4HSRsOAtk50IcWb9qEeIfq4i92khbXQvb52yRMAXrt4BBjc3HgnFK4F5gb1KUdLnCpM9QN+A==}
dependencies: dependencies:
'@protobuf-ts/runtime': 2.2.2 '@protobuf-ts/runtime': 2.2.2
sub-events: 1.8.9 sub-events: 1.8.9

17
src/components/Connection.tsx

@ -57,7 +57,7 @@ export const Connection = (): JSX.Element => {
}} }}
> >
<Card> <Card>
<div className="w-full max-w-3xl p-10"> <div className="flex w-full max-w-3xl justify-between p-10">
{state.deviceStatus === {state.deviceStatus ===
Types.DeviceStatusEnum.DEVICE_DISCONNECTED ? ( Types.DeviceStatusEnum.DEVICE_DISCONNECTED ? (
<div className="space-y-2"> <div className="space-y-2">
@ -89,6 +89,21 @@ export const Connection = (): JSX.Element => {
)} )}
</div> </div>
)} )}
<div className="rounded-md bg-secondaryDark p-2">
{state.logs.map((log, index) => (
<div className="flex">
<div>
[
{log.date.toLocaleTimeString(undefined, {
hour: '2-digit',
minute: '2-digit',
})}
]
</div>
<div key={index}>{log.message}</div>
</div>
))}
</div>
</div> </div>
</Card> </Card>
</Modal> </Modal>

5
src/core/connection.ts

@ -2,6 +2,7 @@ import { connType } from '@core/slices/appSlice';
import { import {
addChannel, addChannel,
addChat, addChat,
addLogEvent,
addMessage, addMessage,
addNode, addNode,
addPosition, addPosition,
@ -86,6 +87,10 @@ export const cleanupListeners = (): void => {
const registerListeners = (): void => { const registerListeners = (): void => {
SettingsManager.debugMode = Protobuf.LogRecord_Level.TRACE; SettingsManager.debugMode = Protobuf.LogRecord_Level.TRACE;
connection.onLogEvent.subscribe((log) => {
store.dispatch(addLogEvent(log));
});
connection.onMeshPacket.subscribe((packet) => { connection.onMeshPacket.subscribe((packet) => {
store.dispatch( store.dispatch(
addRoute({ addRoute({

6
src/core/slices/meshtasticSlice.ts

@ -58,6 +58,7 @@ interface MeshtasticState {
hostOverrideEnabled: boolean; hostOverrideEnabled: boolean;
hostOverride: string; hostOverride: string;
chats: ChatEntries; chats: ChatEntries;
logs: Types.LogEventPacket[];
} }
const initialState: MeshtasticState = { const initialState: MeshtasticState = {
@ -76,12 +77,16 @@ const initialState: MeshtasticState = {
localStorage.getItem('hostOverrideEnabled') === 'true' ?? false, localStorage.getItem('hostOverrideEnabled') === 'true' ?? false,
hostOverride: localStorage.getItem('hostOverride') ?? '', hostOverride: localStorage.getItem('hostOverride') ?? '',
chats: {}, chats: {},
logs: [],
}; };
export const meshtasticSlice = createSlice({ export const meshtasticSlice = createSlice({
name: 'meshtastic', name: 'meshtastic',
initialState, initialState,
reducers: { reducers: {
addLogEvent: (state, action: PayloadAction<Types.LogEventPacket>) => {
state.logs.push(action.payload);
},
setDeviceStatus: (state, action: PayloadAction<Types.DeviceStatusEnum>) => { setDeviceStatus: (state, action: PayloadAction<Types.DeviceStatusEnum>) => {
state.deviceStatus = action.payload; state.deviceStatus = action.payload;
}, },
@ -276,6 +281,7 @@ export const meshtasticSlice = createSlice({
}); });
export const { export const {
addLogEvent,
setDeviceStatus, setDeviceStatus,
setLastMeshInterraction, setLastMeshInterraction,
setReady, setReady,

Loading…
Cancel
Save