Skip to content

Commit

Permalink
feat(device): add rpio library
Browse files Browse the repository at this point in the history
- add noe-rpio library
- replace tsdoc with jsdoc eslint plugin
  • Loading branch information
Jozwiaczek committed Jun 20, 2021
1 parent b3d0faa commit 98648a8
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 53 deletions.
8 changes: 5 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ module.exports = {
'plugin:jest/style',
'plugin:testing-library/react',
'plugin:cypress/recommended',
'plugin:jsdoc/recommended',
],
plugins: ['simple-import-sort', 'better-styled-components', 'eslint-plugin-tsdoc'],
plugins: ['simple-import-sort', 'better-styled-components'],
rules: {
'no-void': 0,
'consistent-return': 0,
Expand All @@ -49,8 +50,6 @@ module.exports = {
},
],

'tsdoc/syntax': 'warn',

'security/detect-non-literal-regexp': 0,
'security/detect-object-injection': 0,

Expand Down Expand Up @@ -88,5 +87,8 @@ module.exports = {
'jest/consistent-test-it': 2,
'jest/lowercase-name': 2,
'jest/require-top-level-describe': 2,

'jsdoc/require-param-type': 0,
'jsdoc/require-returns-type': 0,
},
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"eslint-plugin-better-styled-components": "^1.1.2",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-jsdoc": "^35.3.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^3.4.0",
Expand All @@ -72,7 +73,6 @@
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"eslint-plugin-testing-library": "^4.6.0",
"eslint-plugin-tsdoc": "^0.2.14",
"husky": "^6.0.0",
"hygen": "^6.1.0",
"lerna": "^4.0.0",
Expand Down
2 changes: 2 additions & 0 deletions packages/device/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ module.exports = {
rules: {
'class-methods-use-this': 0,
'@typescript-eslint/no-unsafe-assignment': 0,
'@typescript-eslint/no-unsafe-call': 0,
'security/detect-non-literal-fs-filename': 0,
},
};
5 changes: 4 additions & 1 deletion packages/device/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
"start": "ts-node --project tsconfig.json src/index.ts"
},
"dependencies": {
"@types/socket.io-client": "^1.4.36",
"rpio": "^2.4.2",
"socket.io-client": "^2.4.0"
},
"devDependencies": {
"@types/node": "^15.12.4",
"@types/rpio": "^2.4.1",
"@types/socket.io-client": "^1.4.36",
"ts-node": "^10.0.0",
"typescript": "^4.2.4"
}
Expand Down
3 changes: 3 additions & 0 deletions packages/device/src/constants/pins.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// All pins must points on physical P1-P40 Raspberry Pi numbering scheme

export const OPEN_STATUS_LIGHT_PIN = 40;
2 changes: 2 additions & 0 deletions packages/device/src/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { default as onInit } from './onInit';
export { default as onOpen } from './onOpen';
7 changes: 7 additions & 0 deletions packages/device/src/hooks/onInit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { OPEN_STATUS_LIGHT_PIN } from '../constants/pins';

const onInit = () => {
rpio.open(OPEN_STATUS_LIGHT_PIN, rpio.OUTPUT, rpio.LOW);
};

export default onInit;
9 changes: 9 additions & 0 deletions packages/device/src/hooks/onOpen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { OPEN_STATUS_LIGHT_PIN } from '../constants/pins';

const onOpen = () => {
rpio.write(OPEN_STATUS_LIGHT_PIN, rpio.HIGH);
rpio.sleep(5);
rpio.write(OPEN_STATUS_LIGHT_PIN, rpio.LOW);
};

export default onOpen;
9 changes: 3 additions & 6 deletions packages/device/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import socketClient from 'socket.io-client';
import { onInit, onOpen } from './hooks';

const socket = socketClient('ws://localhost:3030');

socket.on('connection', () => {
console.log('test');
});
onInit();
onOpen();
107 changes: 65 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,15 @@
resolved "https://registry.yarnpkg.com/@emotion/weak-memoize/-/weak-memoize-0.2.5.tgz#8eed982e2ee6f7f4e44c253e12962980791efd46"
integrity sha512-6U71C2Wp7r5XtFtQzYrW5iKFT67OixrSxjI4MptCHzdSVlgabczzqLe0ZSgnub/5Kp4hSbpDB1tMytZY9pwxxA==

"@es-joy/jsdoccomment@^0.8.0-alpha.2":
version "0.8.0-alpha.2"
resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.8.0-alpha.2.tgz#78585147d8e6231270374dae528fe5b7b5587b5a"
integrity sha512-fjRY13Bh8sxDZkzO27U2R9L6xFqkh5fAbHuMGvGLXLfrTes8nTTMyOi6wIPt+CG0XPAxEUge8cDjhG+0aag6ew==
dependencies:
comment-parser "^1.1.5"
esquery "^1.4.0"
jsdoc-type-pratt-parser "1.0.0-alpha.23"

"@eslint/eslintrc@^0.4.2":
version "0.4.2"
resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.4.2.tgz#f63d0ef06f5c0c57d76c4ab5f63d3835c51b0179"
Expand Down Expand Up @@ -2821,21 +2830,6 @@
resolved "https://registry.yarnpkg.com/@mdx-js/util/-/util-1.6.22.tgz#219dfd89ae5b97a8801f015323ffa4b62f45718b"
integrity sha512-H1rQc1ZOHANWBvPcW+JpGwr+juXSxM8Q8YCkm3GhZd8REu1fHR3z99CErO1p9pkcfcxZnMdIZdIsXkOHY0NilA==

"@microsoft/tsdoc-config@0.15.2":
version "0.15.2"
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc-config/-/tsdoc-config-0.15.2.tgz#eb353c93f3b62ab74bdc9ab6f4a82bcf80140f14"
integrity sha512-mK19b2wJHSdNf8znXSMYVShAHktVr/ib0Ck2FA3lsVBSEhSI/TfXT7DJQkAYgcztTuwazGcg58ZjYdk0hTCVrA==
dependencies:
"@microsoft/tsdoc" "0.13.2"
ajv "~6.12.6"
jju "~1.4.0"
resolve "~1.19.0"

"@microsoft/tsdoc@0.13.2":
version "0.13.2"
resolved "https://registry.yarnpkg.com/@microsoft/tsdoc/-/tsdoc-0.13.2.tgz#3b0efb6d3903bd49edb073696f60e90df08efb26"
integrity sha512-WrHvO8PDL8wd8T2+zBGKrMwVL5IyzR3ryWUsl0PXgEV0QHup4mTLi0QcATefGI6Gx9Anu7vthPyyyLpY0EpiQg==

"@mrmlnc/readdir-enhanced@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
Expand Down Expand Up @@ -4637,6 +4631,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.17.3.tgz#6d327abaa4be34a74e421ed6409a0ae2f47f4c3d"
integrity sha512-e6ZowgGJmTuXa3GyaPbTGxX17tnThl2aSSizrFthQ7m9uLGZBXiGhgE55cjRZTF5kjZvYn9EOPOMljdjwbflxw==

"@types/node@^15.12.4":
version "15.12.4"
resolved "https://registry.yarnpkg.com/@types/node/-/node-15.12.4.tgz#e1cf817d70a1e118e81922c4ff6683ce9d422e26"
integrity sha512-zrNj1+yqYF4WskCMOHwN+w9iuD12+dGm0rQ35HLl9/Ouuq52cEtd0CH9qMgrdNmi5ejC1/V7vKEXYubB+65DkA==

"@types/nodemailer@^6.4.2":
version "6.4.2"
resolved "https://registry.yarnpkg.com/@types/nodemailer/-/nodemailer-6.4.2.tgz#d8ee254c969e6ad83fb9a0a0df3a817406a3fa3b"
Expand Down Expand Up @@ -4769,6 +4768,13 @@
dependencies:
"@types/node" "*"

"@types/rpio@^2.4.1":
version "2.4.1"
resolved "https://registry.yarnpkg.com/@types/rpio/-/rpio-2.4.1.tgz#36852780acaaa4b2986a87b55ba65133b53b2c84"
integrity sha512-w2r7DWV7qy6tzsAchE/dXNnHM7M8czHlamIExttaXqsaVFgLThVIxaD303As3cS/kbQdb4FR3JOBTl/A6rfRNw==
dependencies:
"@types/node" "*"

"@types/scheduler@*":
version "0.16.1"
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.1.tgz#18845205e86ff0038517aab7a18a62a6b9f71275"
Expand Down Expand Up @@ -5490,7 +5496,7 @@ ajv-keywords@^3.1.0, ajv-keywords@^3.4.1, ajv-keywords@^3.5.2:
resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.5.2.tgz#31f29da5ab6e00d1c2d329acf7b5929614d5014d"
integrity sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==

ajv@6.12.6, ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5, ajv@~6.12.6:
ajv@6.12.6, ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.2, ajv@^6.12.3, ajv@^6.12.4, ajv@^6.12.5:
version "6.12.6"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.6.tgz#baf5a62e802b07d977034586f8c3baf5adf26df4"
integrity sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==
Expand Down Expand Up @@ -6375,7 +6381,7 @@ binary-extensions@^2.0.0:
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==

bindings@^1.5.0:
bindings@^1.5.0, bindings@~1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df"
integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==
Expand Down Expand Up @@ -7499,7 +7505,7 @@ commander@^7.2.0:
resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7"
integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==

comment-parser@^1.1.2:
comment-parser@1.1.5, comment-parser@^1.1.2, comment-parser@^1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.1.5.tgz#453627ef8f67dbcec44e79a9bd5baa37f0bce9b2"
integrity sha512-RePCE4leIhBlmrqiYTvaqEeGYg7qpSl4etaIabKtdOQVi+mSTIBBklGUwIr79GXYnl3LpMwmDw4KeR2stNc6FA==
Expand Down Expand Up @@ -9527,6 +9533,21 @@ eslint-plugin-jest@^24.1.0, eslint-plugin-jest@^24.3.6:
dependencies:
"@typescript-eslint/experimental-utils" "^4.0.1"

eslint-plugin-jsdoc@^35.3.0:
version "35.3.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-35.3.0.tgz#375410bc990b54d1a394b545b9faa92d8e05a065"
integrity sha512-caPF26GcTqU8e83kj6Zp5RLCNgf9ya8rGNxtk1aDAiUCF5KMqTKmOt28sjcejL99b0py3EC0ds8dOXsoFDVahA==
dependencies:
"@es-joy/jsdoccomment" "^0.8.0-alpha.2"
comment-parser "1.1.5"
debug "^4.3.1"
esquery "^1.4.0"
jsdoc-type-pratt-parser "^1.0.4"
lodash "^4.17.21"
regextras "^0.8.0"
semver "^7.3.5"
spdx-expression-parse "^3.0.1"

eslint-plugin-jsx-a11y@^6.3.1, eslint-plugin-jsx-a11y@^6.4.1:
version "6.4.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.4.1.tgz#a2d84caa49756942f42f1ffab9002436391718fd"
Expand Down Expand Up @@ -9629,14 +9650,6 @@ eslint-plugin-testing-library@^4.6.0:
dependencies:
"@typescript-eslint/experimental-utils" "^4.24.0"

eslint-plugin-tsdoc@^0.2.14:
version "0.2.14"
resolved "https://registry.yarnpkg.com/eslint-plugin-tsdoc/-/eslint-plugin-tsdoc-0.2.14.tgz#e32e7c1df8af7b3009c252590bec07a1030afbf2"
integrity sha512-fJ3fnZRsdIoBZgzkQjv8vAj6NeeOoFkTfgosj6mKsFjX70QV256sA/wq+y/R2+OL4L8E79VVaVWrPeZnKNe8Ng==
dependencies:
"@microsoft/tsdoc" "0.13.2"
"@microsoft/tsdoc-config" "0.15.2"

eslint-scope@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848"
Expand Down Expand Up @@ -12017,7 +12030,7 @@ is-color-stop@^1.0.0:
rgb-regex "^1.0.1"
rgba-regex "^1.0.0"

is-core-module@^2.0.0, is-core-module@^2.1.0, is-core-module@^2.2.0, is-core-module@^2.4.0:
is-core-module@^2.0.0, is-core-module@^2.2.0, is-core-module@^2.4.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.4.0.tgz#8e9fc8e15027b011418026e98f0e6f4d86305cc1"
integrity sha512-6A2fkfq1rfeQZjxrZJGerpLCTHRNEBiSgnu0+obeJpEPZRUooHgsizvzv0ZjJwOz3iWIHdJtVWJ/tmPr3D21/A==
Expand Down Expand Up @@ -13375,11 +13388,6 @@ jest@^27.0.4:
import-local "^3.0.2"
jest-cli "^27.0.4"

jju@~1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/jju/-/jju-1.4.0.tgz#a3abe2718af241a2b2904f84a625970f389ae32a"
integrity sha1-o6vicYryQaKykE+EpiWXDzia4yo=

js-beautify@^1.6.14:
version "1.13.13"
resolved "https://registry.yarnpkg.com/js-beautify/-/js-beautify-1.13.13.tgz#756907d1728f329f2b84c42efd56ad17514620bf"
Expand Down Expand Up @@ -13426,6 +13434,16 @@ jsbn@~0.1.0:
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
integrity sha1-peZUwuWi3rXyAdls77yoDA7y9RM=

jsdoc-type-pratt-parser@1.0.0-alpha.23:
version "1.0.0-alpha.23"
resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-1.0.0-alpha.23.tgz#01c232d92b99b7e7ef52235ab8c9115137426639"
integrity sha512-COtimMd97eo5W0h6R9ISFj9ufg/9EiAzVAeQpKBJ1xJs/x8znWE155HGBDR2rwOuZsCes1gBXGmFVfvRZxGrhg==

jsdoc-type-pratt-parser@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-1.0.4.tgz#5750d2d32ffb001866537d3baaedea7cf84c7036"
integrity sha512-jzmW9gokeq9+bHPDR1nCeidMyFUikdZlbOhKzh9+/nJqB75XhpNKec1/UuxW5c4+O+Pi31Gc/dCboyfSm/pSpQ==

jsdoctypeparser@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/jsdoctypeparser/-/jsdoctypeparser-9.0.0.tgz#8c97e2fb69315eb274b0f01377eaa5c940bd7b26"
Expand Down Expand Up @@ -15217,7 +15235,7 @@ mz@^2.4.0:
object-assign "^4.0.1"
thenify-all "^1.0.0"

nan@^2.12.1:
nan@^2.12.1, nan@^2.14.1:
version "2.14.2"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.2.tgz#f5376400695168f4cc694ac9393d0c9585eeea19"
integrity sha512-M2ufzIiINKCuDfBSAUr1vWQ+vuVcA9kqx8JJUsbQi6yf1uGRyb7HfpdfUr5qLXf3B/t8dPvcjhKMmlfnP47EzQ==
Expand Down Expand Up @@ -18366,6 +18384,11 @@ regexpu-core@^4.7.1:
unicode-match-property-ecmascript "^1.0.4"
unicode-match-property-value-ecmascript "^1.2.0"

regextras@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/regextras/-/regextras-0.8.0.tgz#ec0f99853d4912839321172f608b544814b02217"
integrity sha512-k519uI04Z3SaY0fLX843MRXnDeG2+vHOFsyhiPZvNLe7r8rD2YNRjq4BQLZZ0oAr2NrtvZlICsXysGNFPGa3CQ==

registry-auth-token@3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/registry-auth-token/-/registry-auth-token-3.3.2.tgz#851fd49038eecb586911115af845260eec983f20"
Expand Down Expand Up @@ -18678,14 +18701,6 @@ resolve@^2.0.0-next.3:
is-core-module "^2.2.0"
path-parse "^1.0.6"

resolve@~1.19.0:
version "1.19.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.19.0.tgz#1af5bf630409734a067cae29318aac7fa29a267c"
integrity sha512-rArEXAgsBG4UgRGcynxWIWKFvh/XZCcS8UJdHhwy91zwAvCZIbcs+vAbflgBnNjYMs/i/i+/Ux6IZhML1yPvxg==
dependencies:
is-core-module "^2.1.0"
path-parse "^1.0.6"

restore-cursor@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-1.0.1.tgz#34661f46886327fed2991479152252df92daa541"
Expand Down Expand Up @@ -18797,6 +18812,14 @@ rollup@^1.31.1:
"@types/node" "*"
acorn "^7.1.0"

rpio@^2.4.2:
version "2.4.2"
resolved "https://registry.yarnpkg.com/rpio/-/rpio-2.4.2.tgz#e16d58f7937cc8b30083c3f8df051f5d9f14a1b3"
integrity sha512-SiWw2VorgUh+0hbu6eJkRGG+luvS9BboXz6PQl8Z49kJ+8Nn7R/b4ohybLIYSMbQqcW1WYqSooadDuv1VOAiFw==
dependencies:
bindings "~1.5.0"
nan "^2.14.1"

rsvp@^4.8.4:
version "4.8.5"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
Expand Down Expand Up @@ -19560,7 +19583,7 @@ spdx-exceptions@^2.1.0:
resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz#3f28ce1a77a00372683eade4a433183527a2163d"
integrity sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==

spdx-expression-parse@^3.0.0:
spdx-expression-parse@^3.0.0, spdx-expression-parse@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz#cf70f50482eefdc98e3ce0a6833e4a53ceeba679"
integrity sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==
Expand Down

0 comments on commit 98648a8

Please sign in to comment.