Skip to content

Commit

Permalink
fix minimum raz 5
Browse files Browse the repository at this point in the history
  • Loading branch information
amatilda committed Apr 19, 2024
1 parent 1721271 commit 92b96bf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 12 deletions.
34 changes: 25 additions & 9 deletions src/sapi/controller_sapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ class ControllerSapiClass {

if (this._test_cmd(this.RAZ7_LICENSE_CMD) == false)
return (ControllerSapiClassStatus.UNSUPPORT_CMD);
if (this.isRazberry() == false)
if (this.isRazberry7() == false)
return (ControllerSapiClassStatus.NOT_RAZBERRY);
status = await this._license_get_nonce(out);
if (status != ControllerSapiClassStatus.OK)
Expand Down Expand Up @@ -421,15 +421,15 @@ class ControllerSapiClass {

private async _begin():Promise<void> {
await this._get_capabilities(this.capabilities);
if (this.isRazberry() == true) {
if (this.isRazberry7() == true) {
await this._license_get(this.license);
await this._get_board_info(this.board_info);
}
}

public async getPower(): Promise<ControllerSapiClassPower> {
const power_get_out:ControllerSapiClassPower = {status: ControllerSapiClassStatus.OK, power_raw:0x0, step:0x1, min:1, max:247};
if (this.isRazberry() == false) {
if (this.isRazberry7() == false) {
power_get_out.status = ControllerSapiClassStatus.NOT_RAZBERRY;
return (power_get_out);
}
Expand All @@ -451,7 +451,7 @@ class ControllerSapiClass {
}

public async setPower(power_raw:number): Promise<ControllerSapiClassStatus> {
if (this.isRazberry() == false)
if (this.isRazberry7() == false)
return (ControllerSapiClassStatus.NOT_RAZBERRY);
const power_set:ControllerSapiClassSerialApiSetup = await this._serial_api_setup(SapiClassSerialAPISetupCmd.SERIAL_API_SETUP_CMD_TX_POWERLEVEL_SET, [power_raw, 0x0]);
if (power_set.status != ControllerSapiClassStatus.OK)
Expand Down Expand Up @@ -557,10 +557,18 @@ class ControllerSapiClass {
return (ControllerSapiClassStatus.OK);
}

private _isRazberry(): boolean {
if (this.capabilities.status != ControllerSapiClassStatus.OK)
return (false);
if (this.capabilities.VendorID == 0x0115 || this.capabilities.VendorID == 0x0147)
return (true);
return (false);
}

public async updateFinware(data:Uint8Array, process:ControllerUpdateProcess|null): Promise<ControllerSapiClassStatus> {
let status:ControllerSapiClassStatus;

if (this.isRazberry() == false)
if (this.isRazberry7() == false)
return (ControllerSapiClassStatus.NOT_RAZBERRY);
status = await this._load_file(0x3A000, data, process);
if (status != ControllerSapiClassStatus.OK)
Expand Down Expand Up @@ -593,10 +601,18 @@ class ControllerSapiClass {
return (this.capabilities);
}

public isRazberry(): boolean {
if (this.capabilities.status != ControllerSapiClassStatus.OK)
public isRazberry5(): boolean {
if (this._isRazberry() == false)
return (false);
if (this.capabilities.VendorID == 0x0115 || this.capabilities.VendorID == 0x0147)
if (this.capabilities.ApiVersion == 0x5)
return (true);
return (false);
}

public isRazberry7(): boolean {
if (this._isRazberry() == false)
return (false);
if (this.capabilities.ApiVersion == 0x7)
return (true);
return (false);
}
Expand All @@ -605,7 +621,7 @@ class ControllerSapiClass {
await this._get_capabilities(this.capabilities);
if (this.capabilities.status != ControllerSapiClassStatus.OK)
return (false);
if (this.isRazberry() == true) {
if (this.isRazberry7() == true) {
await this._license_get(this.license);
await this._get_board_info(this.board_info);
}
Expand Down
4 changes: 3 additions & 1 deletion src/section/controller_ui_section_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ControllerUiSectionInfoClass extends ControllerUiSectionClass {
}

private async _power_init(): Promise<boolean> {
if (this.razberry.isRazberry() == false)
if (this.razberry.isRazberry7() == false)
return (false);
this.log.infoStart(ControllerUiLangClassId.MESSAGE_READ_POWER);
const power:ControllerSapiClassPower = await this.razberry.getPower();
Expand Down Expand Up @@ -129,6 +129,8 @@ class ControllerUiSectionInfoClass extends ControllerUiSectionClass {
private async _region_init(): Promise<boolean> {
let i:number, el_option_str:string, el_select:HTMLElement;

if (this.razberry.isRazberry5() == true)
return (false);
this.log.infoStart(ControllerUiLangClassId.MESSAGE_READ_REGION);
const region_info:ControllerSapiClassRegion = await this.razberry.getRegion();
switch (region_info.status) {
Expand Down
2 changes: 1 addition & 1 deletion src/section/controller_ui_section_license.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class ControllerUiSectionLicenseClass extends ControllerUiSectionClass {
}

private async _begin(): Promise<boolean> {
if (this.razberry.isRazberry() == false)
if (this.razberry.isRazberry7() == false)
return (false);
const uuid_str_hex:string|undefined = this._board_info_init();
const crc16:number|undefined = this._license_init();
Expand Down
2 changes: 1 addition & 1 deletion src/section/controller_ui_section_update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class ControllerUiSectionUpdateClass extends ControllerUiSectionClass {
}

private async _begin(): Promise<boolean> {
if (this.razberry.isRazberry() == false)
if (this.razberry.isRazberry7() == false)
return (false);
return (this._update_init());
}
Expand Down

0 comments on commit 92b96bf

Please sign in to comment.