Skip to content

Commit

Permalink
For beta, added sapi output to log.
Browse files Browse the repository at this point in the history
  • Loading branch information
amatilda committed Aug 26, 2024
1 parent be3f896 commit 5cc4757
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serial-api-web-tools",
"version": "0.0.15",
"version": "0.0.16",
"description": "This set tools allows to configure Z-Wave.Me hardware",
"main": "src/main.ts",
"scripts": {
Expand Down
7 changes: 7 additions & 0 deletions src/other/define.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export {WEB_TOOLS_VERSION, WEB_TOOLS_BETA};

declare const __VERSION__: string;
declare const __BETA__: boolean;

const WEB_TOOLS_VERSION:string = __VERSION__;
const WEB_TOOLS_BETA:boolean = __BETA__;
18 changes: 17 additions & 1 deletion src/other/utilities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { sleep, checksum, calcSigmaCRC16, costruct_int, hexToBytes, arrayToStringHex, versionNumberToString, intToBytearrayLsbMsb, intToBytearrayMsbLsb, versionNumberToStringSlave, numberToStringHex, conv2Decimal, toString,
conv2DecimalPadding, version_str_to_int, version_int_to_str
conv2DecimalPadding, version_str_to_int, version_int_to_str, splitHexBuff
};

function toString(array:Array<number>): string {
Expand Down Expand Up @@ -38,6 +38,22 @@ function arrayToStringHex(data:Array<number>|Uint8Array):string {
return (str_hex);
}

function splitHexBuff(data:Array<number>|Uint8Array):string {
let str_hex:string, i:number;

str_hex = "";
i = 0x0;
while (true) {
str_hex = str_hex + data[i].toString(0x10).padStart(2, '0').toUpperCase();
i++;
if (i >= data.length)
break ;
str_hex = str_hex + " ";
}
return (str_hex);
}


function hexToBytes(hex:string):Array<number>|undefined {
let i:number;

Expand Down
6 changes: 6 additions & 0 deletions src/sapi/sapi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import {sleep, checksum, calcSigmaCRC16} from "../other/utilities";
import {WEB_TOOLS_BETA} from "../other/define"
import {splitHexBuff} from "../other/utilities"

export {SapiClass, SapiClassStatus, SapiClassFuncId, SapiClassRet, SapiClassSerialAPISetupCmd, SapiSerialOptionFilters, SapiClassNodeIdBaseType, SapiClassDetect, SapiClassDetectType, SapiClassDetectTypeFunc, SapiClassDetectWait, SapiClassUpdateProcess};

Expand Down Expand Up @@ -431,6 +433,8 @@ class SapiClass {
const writer = this.port.writable.getWriter();
await writer.write(data_uint8);
writer.releaseLock();
if (WEB_TOOLS_BETA == true)
console.log(">> ", splitHexBuff(data_uint8));
return (true);
}

Expand Down Expand Up @@ -639,6 +643,8 @@ class SapiClass {
}
await this._sendAck();
out.raw = [this.SOF, len_data].concat(buff_data);
if (WEB_TOOLS_BETA == true)
console.log("<< ", splitHexBuff(out.raw));
out.cmd = out.raw[0x3];
out.data = out.raw.slice(0x4, out.raw.length - 0x1);
return (out);
Expand Down
5 changes: 2 additions & 3 deletions src/ui_define.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import {WEB_TOOLS_VERSION} from "./other/define"

export {ControllerUiDefineClass, TABLE_NAME_LICENSE_YES, TABLE_NAME_LICENSE_NO, NAME_APP_VERSION_FULL};

const TABLE_NAME_LICENSE_YES:string = '<input disabled="disabled" checked type="checkbox">';
const TABLE_NAME_LICENSE_NO:string = '<input disabled="disabled" type="checkbox">';

declare const WEB_TOOLS_VERSION : string;


enum ControllerUiDefineClass
{
NAME_APP = "SerialAPIWebTools",
Expand Down
9 changes: 4 additions & 5 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function version_int_to_str(version, min) {
}

const web_tools_version = version_int_to_str(version_str_to_int(package.version), 0x3);
const web_tools_beta = ((version_str_to_int(package.version) & 0xFF) == 0x0)? false:true;

function func_common(env, argv, entry_patch, out_filename, library_name) {

Expand All @@ -60,7 +61,8 @@ function func_common(env, argv, entry_patch, out_filename, library_name) {
plugins: [
new MiniCssExtractPlugin(),
new webpack.DefinePlugin({
WEB_TOOLS_VERSION: JSON.stringify(web_tools_version),
__VERSION__: JSON.stringify(web_tools_version),
__BETA__: JSON.stringify(web_tools_beta),
})
],
entry: entry_patch,
Expand Down Expand Up @@ -104,8 +106,5 @@ function func_common(env, argv, entry_patch, out_filename, library_name) {
return (config);
};
module.exports.common = func_common;
if ((version_str_to_int(package.version) & 0xFF) == 0x0)
module.exports.beta = false;
else
module.exports.beta = true;
module.exports.beta = web_tools_beta;
module.exports.web_tools_version = web_tools_version

0 comments on commit 5cc4757

Please sign in to comment.