Skip to content

Commit

Permalink
Merge pull request #3 from 5FNSaaS/edit-property
Browse files Browse the repository at this point in the history
Add MNID/PAT property on "iotcam nodes"
  • Loading branch information
rootkwak528 authored Oct 6, 2021
2 parents 0b10dfd + b5ecdc9 commit 1bbef45
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 18 deletions.
17 changes: 17 additions & 0 deletions body/pose-detection-iotcam/pose-detection-iotcam.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
monitorPort: {value: 1882, validate:RED.validators.number()},
rtspPort: {value: 1886, validate:RED.validators.number()},
dataSocketUrl: {value: 'ws://localhost:1880/ws/data'},
smartthingsMnid: {value: ""},
smartthingsPat: {value: ""},
},
inputs: 1,
outputs: 1,
Expand All @@ -22,6 +24,11 @@
</script>

<script type="text/html" data-template-name="pose-detection-iotcam">
<div class="form-tips" style="margin-bottom:10px;">
<b>Note:</b> You can check your Smartthings MNID on <b><a href="https://smartthings.developer.samsung.com/partner/dashboard" target="_blank">this page</a>.
And you can also generate your Smartthings Personal Access Token(PAT) on <b><a href="https://account.smartthings.com/tokens" target="_blank">this page</a>.</b>
</div>

<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
Expand All @@ -46,6 +53,16 @@
<label for="node-input-dataSocketUrl"><i class="fa fa-tag"></i> Data Socket Url</label>
<input type="text" id="node-input-dataSocketUrl" placeholder="(default) 'ws://localhost:1880/ws/data'">
</div>

<div class="form-row">
<label for="node-input-smartthingsMnid"><i class="fa fa-tag"></i> Smartthings MNID</label>
<input type="text" id="node-input-smartthingsMnid">
</div>

<div class="form-row">
<label for="node-input-smartthingsPat"><i class="fa fa-tag"></i> Smartthings PAT</label>
<input type="text" id="node-input-smartthingsPat">
</div>
</script>

<script type="text/html" data-help-name="pose-detection-iotcam">
Expand Down
11 changes: 1 addition & 10 deletions body/pose-detection-iotcam/pose-detection-iotcam.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const ws = require('ws')
const http = require('http')
const cors = require('cors')
const express = require('express')
require("dotenv").config()


module.exports = function(RED) {
Expand Down Expand Up @@ -455,13 +454,6 @@ module.exports = function(RED) {

RED.nodes.createNode(this, config)
let rtspStream
console.log('hjello')

// .env variable
// .env로부터 변수 호출
const mnid = process.env.SAMSUNG_MNID
const token = process.env.SAMSUNG_TOKEN
console.log(mnid, token)

// listener to receive messages from the up-stream nodes in a flow.
this.on('input', (msg, send, done) => {
Expand Down Expand Up @@ -534,7 +526,7 @@ module.exports = function(RED) {
// newStream 생성
rtspStream = new newStream({
name: 'name',
streamUrl: `rtsps://${mnid}:${token}@${rtspUrl}`,
streamUrl: `rtsps://${config.smartthingsMnid}:${config.smartthingsPat}@${rtspUrl}`,
wsPort: rtspPort,
ffmpegOptions: { // options ffmpeg flags
'-stats': '', // an option with no neccessary value uses a blank string
Expand All @@ -543,7 +535,6 @@ module.exports = function(RED) {
})
})

// :1880/ws/monitor >> :1881
httpServer.listen(rtspPort)

// return HTML document to the client.
Expand Down
17 changes: 17 additions & 0 deletions hand/hand-detection-iotcam/hand-detection-iotcam.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
monitorPort: {value: 1884, validate:RED.validators.number()},
rtspPort: {value: 1886, validate:RED.validators.number()},
dataSocketUrl: {value: 'ws://localhost:1880/ws/data'},
smartthingsMnid: {value: ""},
smartthingsPat: {value: ""},
},
inputs: 1,
outputs: 1,
Expand All @@ -22,6 +24,11 @@
</script>

<script type="text/html" data-template-name="hand-detection-iotcam">
<div class="form-tips" style="margin-bottom:10px;">
<b>Note:</b> You can check your Smartthings MNID on <b><a href="https://smartthings.developer.samsung.com/partner/dashboard" target="_blank">this page</a>.
And you can also generate your Smartthings Personal Access Token(PAT) on <b><a href="https://account.smartthings.com/tokens" target="_blank">this page</a>.</b>
</div>

<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
Expand All @@ -46,6 +53,16 @@
<label for="node-input-dataSocketUrl"><i class="fa fa-tag"></i> Data Socket Url</label>
<input type="text" id="node-input-dataSocketUrl" placeholder="(default) 'ws://localhost:1880/ws/data'">
</div>

<div class="form-row">
<label for="node-input-smartthingsMnid"><i class="fa fa-tag"></i> Smartthings MNID</label>
<input type="text" id="node-input-smartthingsMnid">
</div>

<div class="form-row">
<label for="node-input-smartthingsPat"><i class="fa fa-tag"></i> Smartthings PAT</label>
<input type="text" id="node-input-smartthingsPat">
</div>
</script>

<script type="text/html" data-help-name="hand-detection-iotcam">
Expand Down
9 changes: 1 addition & 8 deletions hand/hand-detection-iotcam/hand-detection-iotcam.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const ws = require('ws')
const http = require('http')
const cors = require('cors')
const express = require('express')
require("dotenv").config()


module.exports = function(RED) {
Expand Down Expand Up @@ -432,11 +431,6 @@ module.exports = function(RED) {
RED.nodes.createNode(this, config)
let rtspStream

// .env variable
// .env로부터 변수 호출
const mnid = process.env.SAMSUNG_MNID
const token = process.env.SAMSUNG_TOKEN

// listener to receive messages from the up-stream nodes in a flow.
this.on('input', (msg, send, done) => {

Expand Down Expand Up @@ -508,7 +502,7 @@ module.exports = function(RED) {
// newStream 생성
rtspStream = new newStream({
name: 'name',
streamUrl: `rtsps://${mnid}:${token}@${rtspUrl}`,
streamUrl: `rtsps://${config.smartthingsMnid}:${config.smartthingsPat}@${rtspUrl}`,
wsPort: rtspPort,
ffmpegOptions: { // options ffmpeg flags
'-stats': '', // an option with no neccessary value uses a blank string
Expand All @@ -517,7 +511,6 @@ module.exports = function(RED) {
})
})

// :1880/ws/monitor >> :1881
httpServer.listen(rtspPort)

// return HTML document to the client.
Expand Down

0 comments on commit 1bbef45

Please sign in to comment.