Skip to content

Commit f9d062e

Browse files
committed
Store pointer address
1 parent 8eb2de9 commit f9d062e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

HomeLive.DeviceExecutor/DeviceExecutor.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class DeviceState : BotState<RoutineType, SwitchConnectionConfig>
1919

2020
public class DeviceExecutor<T>(DeviceState cfg) : SwitchRoutineExecutor<T>(cfg) where T : DeviceState
2121
{
22+
private static ulong BoxStartAddress = 0;
23+
2224
public override string GetSummary()
2325
{
2426
var current = Config.CurrentRoutineType;
@@ -62,6 +64,7 @@ public async Task Connect(CancellationToken token)
6264
public void Disconnect()
6365
{
6466
HardStop();
67+
BoxStartAddress = 0;
6568
if(Connection.Connected)
6669
Connection.Disconnect();
6770
}
@@ -97,7 +100,10 @@ public async Task<ulong> GetBoxStartOffset(CancellationToken token)
97100
if (!Connection.Connected)
98101
throw new InvalidOperationException("No remote connection");
99102

100-
return await SwitchConnection.PointerAll(HomeDataOffsets.BoxStartPointer, token).ConfigureAwait(false);
103+
if (BoxStartAddress == 0)
104+
BoxStartAddress = await SwitchConnection.PointerAll(HomeDataOffsets.BoxStartPointer, token).ConfigureAwait(false);
105+
106+
return BoxStartAddress;
101107
}
102108

103109
public async Task<byte[]> ReadBoxData(int box, CancellationToken token)

0 commit comments

Comments
 (0)