Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using Autofac;
using BrickController2.DeviceManagement.CaDA;
using BrickController2.DeviceManagement.JieStar;
using BrickController2.DeviceManagement.MouldKing;
using BrickController2.Droid.PlatformServices.BluetoothLE;
using BrickController2.Droid.PlatformServices.DeviceManagement.CaDA;
using BrickController2.Droid.PlatformServices.DeviceManagement.JieStar;
using BrickController2.Droid.PlatformServices.DeviceManagement.MouldKing;
using BrickController2.Droid.PlatformServices.GameController;
using BrickController2.Droid.PlatformServices.Infrared;
Expand Down Expand Up @@ -32,6 +34,7 @@ protected override void Load(ContainerBuilder builder)
builder.RegisterType<CameraPermission>().As<ICameraPermission>().InstancePerDependency();
builder.RegisterType<MKPlatformService>().As<IMKPlatformService>().SingleInstance();
builder.RegisterType<CaDAPlatformService>().As<ICaDAPlatformService>().SingleInstance();
builder.RegisterType<JieStarPlatformService>().As<IJieStarPlatformService>().SingleInstance();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using BrickController2.DeviceManagement.JieStar;
using BrickController2.Protocols;

namespace BrickController2.Droid.PlatformServices.DeviceManagement.JieStar;

public class JieStarPlatformService : IJieStarPlatformService
{
private const int HeaderOffset = 15;
private const int PayloadLength = 24;

public bool TryGetRfPayload(byte ctxValue2, byte[] rawData, out byte[] rfPayload)
{
rfPayload = new byte[PayloadLength];
int payloadLength = CryptTools.GetRfPayload(JieStarProtocol.SeedArray, JieStarProtocol.HeaderArray, rawData, HeaderOffset, JieStarProtocol.CTXValue1, ctxValue2, rfPayload);

// fill rest of array
for (int index = payloadLength; index < PayloadLength; index++)
{
rfPayload[index] = (byte)(index + 1);
}

return true;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Autofac;
using BrickController2.DeviceManagement.CaDA;
using BrickController2.DeviceManagement.JieStar;
using BrickController2.DeviceManagement.MouldKing;
using BrickController2.PlatformServices.BluetoothLE;
using BrickController2.PlatformServices.InputDeviceService;
Expand All @@ -9,6 +10,7 @@
using BrickController2.PlatformServices.SharedFileStorage;
using BrickController2.Windows.PlatformServices.BluetoothLE;
using BrickController2.Windows.PlatformServices.DeviceManagement.CaDA;
using BrickController2.Windows.PlatformServices.DeviceManagement.JieStar;
using BrickController2.Windows.PlatformServices.DeviceManagement.MouldKing;
using BrickController2.Windows.PlatformServices.GameController;
using BrickController2.Windows.PlatformServices.Infrared;
Expand All @@ -31,5 +33,6 @@ protected override void Load(ContainerBuilder builder)
builder.RegisterType<BluetoothPermission>().As<IBluetoothPermission>().InstancePerDependency();
builder.RegisterType<MKPlatformService>().As<IMKPlatformService>().SingleInstance();
builder.RegisterType<CaDAPlatformService>().As<ICaDAPlatformService>().SingleInstance();
builder.RegisterType<JieStarPlatformService>().As<IJieStarPlatformService>().SingleInstance();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using BrickController2.DeviceManagement.JieStar;
using BrickController2.Protocols;

namespace BrickController2.Windows.PlatformServices.DeviceManagement.JieStar;

public class JieStarPlatformService : IJieStarPlatformService
{
private const int HeaderOffset = 15;
private const int PayloadOffset = 3;
private const int PayloadLength = 24 + PayloadOffset;

public bool TryGetRfPayload(byte ctxValue2, byte[] rawData, out byte[] rfPayload)
{
rfPayload = new byte[PayloadLength];
int payloadLength = CryptTools.GetRfPayload(JieStarProtocol.SeedArray, JieStarProtocol.HeaderArray, rawData, HeaderOffset, JieStarProtocol.CTXValue1, ctxValue2, rfPayload, PayloadOffset);

// fill rest of array
for (int index = payloadLength + PayloadOffset; index < PayloadLength; index++)
{
rfPayload[index] = (byte)(index + 1);
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private void AddDevices(IEnumerable<Gamepad> gamepads)
int controllerNumber = GetFirstUnusedInputDeviceNumber();
var newController = new GamepadController(InputDeviceEventService, gamepad!, rawController, controllerNumber, dispatcher!.CreateTimer());

// UniquePersistantDeviceId looks like "{wgi/nrid/]Xd\\h-M1mO]-il0l-4L\\-Gebf:^3->kBRhM-d4}\0"
// UniquePersistentDeviceId looks like "{wgi/nrid/]Xd\\h-M1mO]-il0l-4L\\-Gebf:^3->kBRhM-d4}\0"
AddInputDevice(newController);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Autofac;
using BrickController2.DeviceManagement.CaDA;
using BrickController2.DeviceManagement.JieStar;
using BrickController2.DeviceManagement.MouldKing;
using BrickController2.iOS.PlatformServices.BluetoothLE;
using BrickController2.iOS.PlatformServices.DeviceManagement.MouldKing;
using BrickController2.iOS.PlatformServices.DeviceManagement.CaDA;
using BrickController2.iOS.PlatformServices.DeviceManagement.JieStar;
using BrickController2.iOS.PlatformServices.DeviceManagement.MouldKing;
using BrickController2.iOS.PlatformServices.GameController;
using BrickController2.iOS.PlatformServices.Infrared;
using BrickController2.iOS.PlatformServices.Localization;
Expand Down Expand Up @@ -32,6 +34,7 @@ protected override void Load(ContainerBuilder builder)
builder.RegisterType<CameraPermission>().As<ICameraPermission>().InstancePerDependency();
builder.RegisterType<MKPlatformService>().As<IMKPlatformService>().SingleInstance();
builder.RegisterType<CaDAPlatformService>().As<ICaDAPlatformService>().SingleInstance();
builder.RegisterType<JieStarPlatformService>().As<IJieStarPlatformService>().SingleInstance();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using BrickController2.DeviceManagement.JieStar;
using BrickController2.Protocols;

namespace BrickController2.iOS.PlatformServices.DeviceManagement.JieStar;

public class JieStarPlatformService : IJieStarPlatformService
{
private const int HeaderOffset = 13;
private const int PayloadLength = 26;

public bool TryGetRfPayload(byte ctxValue2, byte[] rawData, out byte[] rfPayload)
{
rfPayload = new byte[PayloadLength];
int payloadLength = CryptTools.GetRfPayload(JieStarProtocol.SeedArray, JieStarProtocol.HeaderArray, rawData, HeaderOffset, JieStarProtocol.CTXValue1, ctxValue2, rfPayload);

// fill rest of array
byte bVar = 0x12; // initial value
for (int index = payloadLength; index < PayloadLength; index++)
{
rfPayload[index] = bVar++;
}

return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ private static bool IsCadaRaceCarRev2(ReadOnlySpan<byte> manufacturerData) => ma
manufacturerData[7] == 0x85;

/// <summary>
/// gets or creates an App-persistant AppIdentifier
/// Gets or creates an app-persistent AppIdentifier.
/// </summary>
/// <param name="preferencesService">reference to preferencesService singleton</param>
/// <param name="preferencesService">Reference to preferencesService singleton.</param>
/// <returns>byte array containing the AppIdentifier</returns>
private static byte[] GetAppIdentifier(IPreferencesService preferencesService)
{
byte[] appIdChecksumMaskArray;
// gets or creates an App-persistant AppIdentifier
// gets or creates an app-persistent AppIdentifier
try
{
if (preferencesService.ContainsKey(APPIDKEY, SECTION))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ public enum DeviceType
MK3_8,
RemoteControl,
SBrickLight,
JieStarSCM4,
JieStarSCM8,
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;

namespace BrickController2.DeviceManagement.JieStar;

/// <summary>
/// Manager for JIESTAR devices
/// </summary>
public interface IJieStarDeviceManager
{
ReadOnlyMemory<byte> GetAppId();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace BrickController2.DeviceManagement.JieStar;

/// <summary>
/// Interface definition for JieStar specific PlatformService
/// </summary>
public interface IJieStarPlatformService
{
bool TryGetRfPayload(byte ctxValue2, byte[] rawData, out byte[] rfPayload);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using Autofac;
using BrickController2.DeviceManagement.DI;
using BrickController2.DeviceManagement.Vendors;

namespace BrickController2.DeviceManagement.JieStar;

/// <summary>
/// Vendor: JIESTAR and all its devices
/// </summary>
internal class JieStar : Vendor<JieStar>
{
public override string VendorName => "JIESTAR";

protected override void Register(VendorBuilder<JieStar> builder)
{
// device manager
builder.ContainerBuilder.RegisterType<JieStarDeviceManager>()
.As<IJieStarDeviceManager>()
.SingleInstance();

// manually added devices
builder.RegisterDevice<JieStarSCM4>()
.WithDeviceFactory(JieStarSCM4.Device1, $"{JieStarSCM4.TypeName} Device 1")
.WithDeviceFactory(JieStarSCM4.Device2, $"{JieStarSCM4.TypeName} Device 2")
.WithDeviceFactory(JieStarSCM4.Device3, $"{JieStarSCM4.TypeName} Device 3");

builder.RegisterDevice<JieStarSCM8>()
.WithDeviceFactory(JieStarSCM8.Device1, $"{JieStarSCM8.TypeName} Device 1")
.WithDeviceFactory(JieStarSCM8.Device2, $"{JieStarSCM8.TypeName} Device 2")
.WithDeviceFactory(JieStarSCM8.Device3, $"{JieStarSCM8.TypeName} Device 3");
}
}
Loading
Loading