File tree Expand file tree Collapse file tree 4 files changed +125
-0
lines changed Expand file tree Collapse file tree 4 files changed +125
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
2
+ *
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ var Gpio = require ( 'gpio' ) ;
17
+ var pin = require ( 'systemio_pin' ) . pin ;
18
+
19
+ var gpio = new Gpio ( ) ;
20
+
21
+ var gpio_led = gpio . open ( {
22
+ pin : pin . led1 ,
23
+ direction : gpio . DIRECTION . OUT
24
+ } , function ( err ) {
25
+ if ( ! err ) {
26
+ gpio_led . writeSync ( true ) ;
27
+
28
+ var interval = setInterval ( function ( ) {
29
+ gpio_led . read ( function ( err , value ) {
30
+ if ( ! err ) {
31
+ console . log ( "read value:%d" , value ) ;
32
+ gpio_led . write ( ! value ) ;
33
+ } else {
34
+ clearInterval ( interval ) ;
35
+ }
36
+ } ) ;
37
+ } , 1000 ) ;
38
+ }
39
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
2
+ *
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ var net = require ( 'net' ) ;
17
+
18
+ var port = 7468 ;
19
+
20
+ var msg = '' ;
21
+ var socket = new net . Socket ( ) ;
22
+
23
+ var address = process . argv [ 2 ] ? process . argv [ 2 ] : "127.0.0.1" ;
24
+
25
+ socket . connect ( port , address ) ;
26
+
27
+ socket . on ( 'data' , function ( data ) {
28
+ msg += data ;
29
+ } ) ;
30
+
31
+ socket . on ( 'end' , function ( ) {
32
+ console . log ( msg ) ;
33
+ socket . end ( ) ;
34
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
2
+ *
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ var net = require ( 'net' ) ;
17
+
18
+ var port = 7468 ;
19
+ var server = net . createServer ( ) ;
20
+
21
+ server . listen ( port , 5 ) ;
22
+
23
+ server . on ( 'connection' , function ( socket ) {
24
+ socket . end ( 'Hello IoT.js' ) ;
25
+ } ) ;
Original file line number Diff line number Diff line change
1
+ /* Copyright 2017-present Samsung Electronics Co., Ltd. and other contributors
2
+ *
3
+ * Licensed under the Apache License, Version 2.0 (the "License");
4
+ * you may not use this file except in compliance with the License.
5
+ * You may obtain a copy of the License at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * Unless required by applicable law or agreed to in writing, software
10
+ * distributed under the License is distributed on an "AS IS" BASIS
11
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ * See the License for the specific language governing permissions and
13
+ * limitations under the License.
14
+ */
15
+
16
+ var pin = { } ;
17
+
18
+ if ( process . platform === 'linux' ) {
19
+ pin . led1 = 20 ;
20
+ } else if ( process . platform === 'nuttx' ) {
21
+ var stm32_pin = require ( 'stm32f4dis' ) . pin ;
22
+ pin . led1 = stm32_pin . PA10 ;
23
+ } else {
24
+ throw new Error ( 'Unsupported platform' ) ;
25
+ }
26
+
27
+ exports . pin = pin ;
You can’t perform that action at this time.
0 commit comments