1
1
using SysBot . Base ;
2
+ using System . Globalization ;
2
3
using System . Text ;
3
4
4
5
namespace HomeLive . DeviceExecutor ;
@@ -19,6 +20,7 @@ public class DeviceState : BotState<RoutineType, SwitchConnectionConfig>
19
20
20
21
public class DeviceExecutor < T > ( DeviceState cfg ) : SwitchRoutineExecutor < T > ( cfg ) where T : DeviceState
21
22
{
23
+ private const decimal BotbaseVersion = 2.4m ;
22
24
private static ulong BoxStartAddress = 0 ;
23
25
24
26
public override string GetSummary ( )
@@ -37,6 +39,8 @@ public override async Task MainLoop(CancellationToken token)
37
39
{
38
40
try
39
41
{
42
+ var botbase = await VerifyBotbaseVersion ( token ) . ConfigureAwait ( false ) ;
43
+ Log ( $ "Valid botbase version: { botbase } ") ;
40
44
( var title , var build ) = await IsRunningHome ( token ) . ConfigureAwait ( false ) ;
41
45
Log ( $ "Valid Title ID ({ title } )") ;
42
46
Log ( $ "Valid Build ID ({ build } )") ;
@@ -95,6 +99,30 @@ private async Task<string> GetBuildID(CancellationToken token)
95
99
return str ;
96
100
}
97
101
102
+ //Thanks Anubis
103
+ //https://github.com/kwsch/SysBot.NET/blob/b26c8c957364efe316573bec4b82e8c5c5a1a60f/SysBot.Pokemon/Actions/PokeRoutineExecutor.cs#L88
104
+ //AGPL v3 License
105
+ public async Task < string > VerifyBotbaseVersion ( CancellationToken token )
106
+ {
107
+ if ( Config . Connection . Protocol is SwitchProtocol . WiFi && ! Connection . Connected )
108
+ throw new InvalidOperationException ( "No remote connection" ) ;
109
+
110
+ var data = await SwitchConnection . GetBotbaseVersion ( token ) . ConfigureAwait ( false ) ;
111
+ var version = decimal . TryParse ( data , CultureInfo . InvariantCulture , out var v ) ? v : 0 ;
112
+ if ( version < BotbaseVersion )
113
+ {
114
+ var protocol = Config . Connection . Protocol ;
115
+ var msg = protocol is SwitchProtocol . WiFi ? "sys-botbase" : "usb-botbase" ;
116
+ msg += $ " version is not supported. Expected version { BotbaseVersion } or greater, and current version is { version } . Please download the latest version from: ";
117
+ if ( protocol is SwitchProtocol . WiFi )
118
+ msg += "https://github.com/olliz0r/sys-botbase/releases/latest" ;
119
+ else
120
+ msg += "https://github.com/Koi-3088/usb-botbase/releases/latest" ;
121
+ throw new Exception ( msg ) ;
122
+ }
123
+ return data ;
124
+ }
125
+
98
126
public async Task < ulong > GetBoxStartOffset ( CancellationToken token )
99
127
{
100
128
if ( ! Connection . Connected )
0 commit comments