Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ClassicOldSong committed Feb 9, 2024
0 parents commit 597c8c9
Show file tree
Hide file tree
Showing 18 changed files with 3,867 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
charset = utf-8
indent_style = tab
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true

[package.json]
indent_style = space

[.eslintrc]
indent_style = space

[.prettierrc]
indent_style = space
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build/*.js
config/*.js
test/*.js
**/*.json
**/*.ef
**/*.eft
**/*.css
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated files
bin/
gen/

# Log Files
*.log
*.log.*

# Temp Files
*~
*.*~
.fuse_*
yarn.lock
cache/
temp/
.DS_Store

# Project files
dist/*
dev/*

# node modules
node_modules/

# local tools
publish
/out
10 changes: 10 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"printWidth": 120,
"tabWidth": 2,
"useTabs": true,
"semi": false,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": true,
"fluid": false
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 SudoMaker Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# LoShark Generic Firmware \[JavaScript only\]

This firmware is designed for the LoShark LoRa USB dongle to work with our official [dashboard](https://su.mk/loshark-app), and can be used as an entry point for developing your own applications on or interfacing the LoShark.

## What is LoShark?
The LoShark LoRa USB dongle is a device that enables wireless communication over long distances using the LoRa protocol. It's perfect for IoT projects and remote communication needs.

## Usage

### Getting Started
1. **Download Firmware:**
- Visit the [release page](https://github.com/SudoMaker/loshark-generic-firmware/tags) and download the latest firmware files: `app.sh`, `resonance_loshark`, and `loshark-sx126x.js`(choose according to your model, `sx1268` for 433MHz and `sx1262` for 915MHz).
2. **Copy Files:**
- Rename the `loshark-sx126x.js` to `loshark.js`
- Connect your LoShark dongle to your computer.
- Transfer the downloaded files to the `app` directory on the MTP server of your LoShark dongle. MTP (Media Transfer Protocol) is a way to manage files on your dongle.
3. **Login to LoShark Shell:**
If you confirm that your dongle has sync enabled, then just skip this step. If not, this step is **essential**.

- Use `PuTTY` (Windows/Linux) or `Tabby` ([download here](https://github.com/Eugeny/tabby) for macOS) to access the LoShark's shell. The shell is like a command center for your dongle.
- Default login:
```
Username: root
Password: loshark
```
- In the shell, type `sync` and press Enter. This ensures your files are properly saved.
4. **Restart:**
- Disconnect and reconnect (power cycle) your LoShark dongle or just run `reboot` in the shell.
5. **Access the Dashboard:**
- Open your web browser and go to [LoShark Dashboard](https://su.mk/loshark-app).

### Enable File Syncing by Default
The first batch LoShark dongles might not sync file changes automatically. To enable this:

1. Log in to the LoShark shell (as described above).
2. Execute the following commands in order:
```
mount / -wo,remount
vi /sbin/init-storage.sh
```
- In `vi`, navigate to the corresponding line, press `o`, then modify the line from `mount /dev/mmcblk0p2 /data || exit 2` to `mount -o sync /dev/mmcblk0p2 /data || exit 2`.
- Save your changes: Press `ESC`, type `:wq`, and press `Enter`.
3. Type `sync` and press Enter.
4. Power cycle your LoShark.

## Building the Firmware

If you would like to change or develop the firmware of your own, you can build it yourself:

### Standard Build
1. Clone this repository to your computer.
2. In the cloned directory, run `pnpm install` in your command line or terminal.
3. Once the installation finishes, execute `pnpm build`.
4. Find the build result in the `dist` folder.

### Unminified Version
- Run `pnpm start` for a continuous dev server that outputs the latest build to the `dev` folder, reflecting file changes in real-time.

## About Resonance
Resonance, the JavaScript runtime, is currently offered as a pre-built binary. We plan to open-source it in a dedicated repo soon.

## Need Help?
If you encounter any issues or have questions, don't hesitate to open an issue.

## License
This project is licensed under the MIT License.
51 changes: 51 additions & 0 deletions config/build.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import path from 'path'

import eslint from '@rollup/plugin-eslint'
import alias from '@rollup/plugin-alias'

const buildTarget = 'loshark'
const chipType = process.env.CHIP_TYPE || 'sx1268'

const inputs = {
loshark: 'src/loshark/index.js'
}

const input = {
[`${buildTarget}-${chipType}`]: inputs[buildTarget]
}

export default {
input,
del: false,
format: 'iife',
target: 'es2015',
devPath: 'dev',
proPath: 'dist',
copyOptions: [[]],
external: [],
globals: {},
esbuild: {
supported: {
bigint: true,
'async-await': true
}
},
define: {
'___CHIP_TYPE___': JSON.stringify(chipType)
},
plugins: [
eslint({
exclude: ['src/static/**.*', '../../../**/**.*']
}),
alias({
entries: {
'utils': path.resolve('./src/utils'),
'system': path.resolve('./src/system')
}
})
],
execCommands: [
// 'killall resonance',
// 'adb push ./dev/app.js /app/app.js'
]
}
88 changes: 88 additions & 0 deletions config/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import path from 'path'
import chalk from 'chalk'
import { deleteSync } from 'del'

// Rollup plugins
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import esbuild from 'rollup-plugin-esbuild'
import progress from 'rollup-plugin-progress'
import execute from 'rollup-plugin-shell'
import copy from 'rollup-plugin-copy-glob'

// build configuration
import userConfig from './build.config.mjs'
const {
del,
input,
output,
format,
target,
external,
globals,
define = {},
devPath: _devPath,
proPath: _proPath,
esbuild: esbuildOptions,
plugins,
copyOptions,
execCommands
} = userConfig

console.log('ENV:', chalk.bold.green(process.env.NODE_ENV || 'development'))

const isProduction = process.env.NODE_ENV === 'production'

const dir = path.normalize(isProduction ? _proPath : _devPath)

// Clear previous builds files
if (del) {
if (isProduction) deleteSync([`${_proPath}/**`])
else deleteSync([`${_devPath}/**`])
}

export default {
input: input || {
main: 'src/main.js'
},
output: output || {
format: format || 'iife',
dir,
sourcemap: !isProduction,
globals
},
external,
plugins: [
copy(...copyOptions, {
verbose: true,
watch: !isProduction
}),
progress({
clearLine: false
}),
esbuild({
target: target || 'es2015',
sourceMap: isProduction,
minify: isProduction,
define: {
'process.env.NODE_ENV': `'${process.env.NODE_ENV}'`,
...define
},
jsxFactory: 'R.c',
jsxFragment: 'R.f',
...esbuildOptions
}),
resolve({
browser: true,
extensions: ['.mjs', '.js', '.jsx', '.json', '.node']
}),
json(),
commonjs(),
execute(execCommands),
...plugins
],
watch: !isProduction && {
include: ['src/**/*.*']
}
}
Loading

0 comments on commit 597c8c9

Please sign in to comment.