Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…_App

# Conflicts:
#	src/cmnds/cmd_eventHandlers.c
#	src/driver/drv_tuyaMCU.c
  • Loading branch information
openshwprojects committed Oct 16, 2022
2 parents d25ced9 + 99f41cc commit f699c57
Show file tree
Hide file tree
Showing 40 changed files with 15,477 additions and 4,988 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
strategy:
fail-fast: false
matrix:
platform: [OpenBK7231T, OpenBK7231N, OpenXR809, OpenBL602, OpenW800]
platform: [OpenBK7231T, OpenBK7231N, OpenXR809, OpenBL602, OpenW800, OpenW600]
steps:
- name: Source checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -97,6 +97,7 @@ jobs:
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}.bin
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}.fls
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}_ota.img
output/${{ needs.refs.outputs.version }}/${{ matrix.platform }}_${{ needs.refs.outputs.version }}_gz.img
if-no-files-found: warn

release:
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
url = https://github.com/openshwprojects/OpenW800.git
[submodule "sdk/OpenW600"]
path = sdk/OpenW600
url = https://github.com/iprak/OpenW600.git
url = https://github.com/openshwprojects/OpenW600.git
4 changes: 4 additions & 0 deletions .releaserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ generateNotes:
- XR809 (XR3, etc)
- BL602
- W800 (W800-C400, WinnerMicro WiFi & Bluetooth), W801
- W600
footerPartial: |
{{#if noteGroups}}
Expand Down Expand Up @@ -106,6 +107,8 @@ generateNotes:
| BL602 | UART Flash | [OpenBL602_{{version}}.bin]({{host}}/{{owner}}/{{repository}}/releases/download/{{version}}/OpenBL602_{{version}}.bin) |
| W800 | OTA Update | [OpenW800_{{version}}_ota.img]({{host}}/{{owner}}/{{repository}}/releases/download/{{version}}/OpenW800_{{version}}_ota.img) |
| W800 | UART Flash | [OpenW800_{{version}}.fls]({{host}}/{{owner}}/{{repository}}/releases/download/{{version}}/OpenW800_{{version}}.fls) |
| W600 | OTA Update | [OpenW600_{{version}}_gz.img]({{host}}/{{owner}}/{{repository}}/releases/download/{{version}}/OpenW600_{{version}}_gz.img) |
| W600 | UART Flash | [OpenW600_{{version}}.fls]({{host}}/{{owner}}/{{repository}}/releases/download/{{version}}/OpenW600_{{version}}.fls) |
CCtr Flash = Tuya cloud Cutter flash
Expand Down Expand Up @@ -158,6 +161,7 @@ publish:
- path: "output/**/*.rbl"
- path: "output/**/*.img"
- path: "output/**/OpenBL602*.bin"
- path: "output/**/OpenW600*"
- path: "output/**/OpenW800*"

success:
Expand Down
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"ms-vscode.cpptools"
]
}
16 changes: 16 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"C_Cpp.formatting": "vcFormat",
"C_Cpp.codeAnalysis.runAutomatically": false,
"C_Cpp.clang_format_style": "{ BasedOnStyle: LLVM, UseTab: Always, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Attach, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }",
"C_Cpp.autocompleteAddParentheses": true,
"files.exclude": {
"**/*.o": true,
"node_modules": true
},
"editor.insertSpaces": false,
"editor.tabSize": 4,
"editor.detectIndentation": false,
"C_Cpp.clang_format_fallbackStyle": "{ BasedOnStyle: LLVM, UseTab: Always, IndentWidth: 4, TabWidth: 4, BreakBeforeBraces: Attach, AllowShortIfStatementsOnASingleLine: false, IndentCaseLabels: false, ColumnLimit: 0, AccessModifierOffset: -4, NamespaceIndentation: All, FixNamespaceComments: false }"
}
32 changes: 25 additions & 7 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
# Building for BK7231T
# Setup

## Editor

Any editor can be used for editing. However, the repository does have settings to ensure consistent formatting when using [Visual Code](https://code.visualstudio.com/). For other editors, please use `tab` instead of `spaces` with `tabSize` of `4` for indentation.

## Nodejs

You would need `nodejs` if you plan on making JavaScript/styling changes. This is to run `gulp` tasks and more things in future.

- Install [nodejs](https://nodejs.org/en/).
- Run `npm install` at the root folder to install dev packages.

Gulp tasks should automatically appear in Explore pane in Visual Code. They can also be invoked from console by running `gulp`.

# Building

## Building for BK7231T

Get the SDK repo:
https://github.com/openshwprojects/OpenBK7231T
Expand All @@ -21,14 +38,12 @@ e.g. `./build_app.sh apps/openbk7231app openbk7231app 1.0.0`.

The output binaries can be found at `apps/<appname>/output/<appversion>`.


# Building for BK7231N
## Building for BK7231N

Same as for BK7231T, but use BK7231N SDK and you also might need to rename project directory from OpenBK7231T_App to OpenBK7231N_App:
https://github.com/openshwprojects/OpenBK7231N


# Building for XR809
## Building for XR809

Get XR809 SDK:
https://github.com/openshwprojects/OpenXR809
Expand All @@ -37,8 +52,8 @@ Checkout [this repository](https://github.com/openshwprojects/OpenBK7231T_App) t

Run ./build_oxr_sharedapp.sh

## Building for BL602

# Building for BL602
Get the SDK repo:
https://github.com/openshwprojects/OpenBL602
Clone it to a folder, e.g. `OpenBL602/`
Expand All @@ -55,8 +70,11 @@ Build using:

The output binaries can be found at `OpenBL602/customer_app/bl602_sharedApp/build_out/bl602_sharedApp.bin`.

## Building for W600

https://github.com/openshwprojects/OpenW600

# Building for W800/W801
## Building for W800/W801

To build for W800, you need our W800 SDK fork:

Expand Down
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ sdk/OpenW800/sharedAppContainer/sharedApp:
@mkdir "sdk/OpenW800/sharedAppContainer"
ln -s "$(shell pwd)/" "sdk/OpenW800/sharedAppContainer/sharedApp"

sdk/OpenW600/sharedAppContainer/sharedApp:
@echo Create symlink for $(APP_NAME) into sdk folder
@mkdir -p "sdk/OpenW600/sharedAppContainer"
ln -s "$(shell pwd)/" "sdk/OpenW600/sharedAppContainer/sharedApp"

# Build main binaries
OpenBK7231T:
$(MAKE) APP_NAME=OpenBK7231T TARGET_PLATFORM=bk7231t SDK_PATH=sdk/OpenBK7231T APPS_BUILD_PATH=../bk7231t_os build-BK7231
Expand Down Expand Up @@ -107,12 +112,24 @@ sdk/OpenW800/tools/w800/csky/bin: submodules
mkdir -p sdk/OpenW800/tools/w800/csky
cd sdk/OpenW800/tools/w800/csky && wget -q "https://occ-oss-prod.oss-cn-hangzhou.aliyuncs.com/resource/1356021/1619529111421/csky-elfabiv2-tools-x86_64-minilibc-20210423.tar.gz" && tar -xf *.tar.gz && rm -f *.tar.gz

sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin: submodules
mkdir -p sdk/OpenW600/tools
cd sdk/OpenW600/tools && tar -xf ../support/*.tar.bz2

.PHONY: OpenW800
OpenW800: sdk/OpenW800/tools/w800/csky/bin sdk/OpenW800/sharedAppContainer/sharedApp
$(MAKE) -C sdk/OpenW800 EXTRA_CCFLAGS=-DPLATFORM_W800 CONFIG_W800_USE_LIB=n CONFIG_W800_TOOLCHAIN_PATH="$(shell realpath sdk/OpenW800/tools/w800/csky/bin)/"
mkdir -p output/$(APP_VERSION)
cp sdk/OpenW800/bin/w800/w800.fls output/$(APP_VERSION)/OpenW800_$(APP_VERSION).fls
cp sdk/OpenW800/bin/w800/w800_ota.img output/$(APP_VERSION)/OpenW800_$(APP_VERSION)_ota.img

.PHONY: OpenW600
OpenW600: sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin sdk/OpenW600/sharedAppContainer/sharedApp
$(MAKE) -C sdk/OpenW600 TOOL_CHAIN_PATH="$(shell realpath sdk/OpenW600/tools/gcc-arm-none-eabi-4_9-2014q4/bin)/" APP_VERSION=$(APP_VERSION)
mkdir -p output/$(APP_VERSION)
cp sdk/OpenW600/bin/w600/w600.fls output/$(APP_VERSION)/OpenW600_$(APP_VERSION).fls
cp sdk/OpenW600/bin/w600/w600_gz.img output/$(APP_VERSION)/OpenW600_$(APP_VERSION)_gz.img

# clean .o files and output directory
.PHONY: clean
clean:
Expand All @@ -121,6 +138,7 @@ clean:
$(MAKE) -C sdk/OpenXR809/src clean
$(MAKE) -C sdk/OpenXR809/project/oxr_sharedApp/gcc clean
$(MAKE) -C sdk/OpenW800 clean
$(MAKE) -C sdk/OpenW600 clean

# Add custom Makefile if required
-include custom.mk
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This repository is named "OpenBK7231T_App", but now it's a multiplatform app, su
- XR809 ([XR3](https://developer.tuya.com/en/docs/iot/xr3-datasheet?id=K98s9168qi49g), etc)
- BL602
- W800 (W800-C400, WinnerMicro WiFi & Bluetooth), W801
- W600 (WinnerMicro chip), W601

Please use automatically compiled binaries from the Releases tab. To build yourself for a given platform, just checkout first our version of SDK and then checkout this app repository into it, details later.

Expand Down
122 changes: 122 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
const gulp = require("gulp");
const uglify = require("gulp-uglify");
const cssnano = require("gulp-cssnano");
const through = require("through2");
const path = require("path");
const fs = require("fs");
const readline = require("readline");

const destination = "new_http.c";

function dumpFileSize() {
return through.obj(function (file, enc, cb) {
console.log(
`Processing ${file.basename}, original length ${file.stat.size}`
);
cb(null, file);
});
}

/** This function injects C for a const field in new_http.c */
function generateCode(field_name, is_script) {
return through.obj(function (file, enc, cb) {
if (file.isBuffer()) {
const contents = file.contents;

let output = String(contents);
output = output.replace(/\"/g, '\\"');
console.log(
`Processing ${file.basename}, reduced length ${contents.length}`
);

const prefix = is_script ? "<script type='text/javascript'>" : "<style>";
const suffix = is_script ? "</script>" : "</style>";
output = `const char ${field_name}[] = "${prefix}${output}${suffix}";`;

const target_path = path.join(path.dirname(file.path), destination);
//console.log(`Updated ${target_path}`);

const rl = readline.createInterface({
input: fs.createReadStream(target_path),
crlfDelay: Infinity,
});

const merged_contents = [];
const marker_start = `//region_start ${field_name}`;
const marker_end = `//region_end ${field_name}`;
let region_state = 0;

rl.on("line", (line) => {
if (line.trim() === marker_start) {
region_state = 1;
merged_contents.push(marker_start);
merged_contents.push(output);
merged_contents.push(marker_end);
} else {
//Skip all existing content lines till region ends
if (region_state === 1) {
if (line.trim() === marker_end) {
region_state = 2;
}
} else {
merged_contents.push(line);
}
}
});

rl.on("close", () => {
if (region_state === 0) {
//Starting marker was not found, append

merged_contents.push("");
merged_contents.push(marker_start);
merged_contents.push(output);
merged_contents.push(marker_end);
}

if (region_state === 1) {
cb(`Ending marker "${marker_end}" was not found.`, file);
} else {
fs.writeFile(
target_path,
merged_contents.join("\r\n"),
"utf8",
(err) => {
cb(err, file);
}
);
}
});

return;
}

cb(null, file);
});
}

function minifyJs() {
return gulp
.src("./src/httpserver/script.js")
.pipe(dumpFileSize())
.pipe(uglify())
.pipe(generateCode("pageScript", true));
}

function minifyHassDiscoveryJs() {
return gulp
.src("./src/httpserver/script_ha_discovery.js")
.pipe(dumpFileSize())
.pipe(uglify())
.pipe(generateCode("ha_discovery_script", true));
}

function minifyCss() {
return gulp
.src("./src/httpserver/style.css")
.pipe(dumpFileSize())
.pipe(cssnano())
.pipe(generateCode("htmlHeadStyle", false));
}

exports.default = gulp.series(minifyJs, minifyHassDiscoveryJs, minifyCss);

0 comments on commit f699c57

Please sign in to comment.