Skip to content

Commit 59f2911

Browse files
committed
2018.11.12. / official release
- initial release
0 parents  commit 59f2911

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+7603
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## PHPoC Shield
2+
PHPoC source codes to use [PHPoC (WiFi) Shield for Arduino](http://www.phpoc.com/phpoc_shield_for_arduino.php).
3+
4+
## Available Web Applications
5+
* Setup
6+
* Web Serial Monitor
7+
* Web Serial Plotter
8+
* Web Remote Push
9+
* Web Remote Slide
10+
* Web Remote Pad
11+
12+
## References
13+
* [PHPoC Shield for Arduino](https://www.phpoc.com/support/manual/p4s-348-r2_user_manual/)
14+
* [PHPoC WiFi Shield for Arduino](https://www.phpoc.com/support/manual/p4s-347-r2_user_manual/)

cmd_smtp.php

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
<?php
2+
3+
define("MAX_DATA_LEN", 1024);
4+
5+
$smtp_to_email = "";
6+
$smtp_to_name = "";
7+
$smtp_subject = "";
8+
$smtp_data = "";
9+
10+
function cmd_smtp_server($cmd)
11+
{
12+
if(count($cmd) < 4)
13+
{
14+
esmtp_msa("", 0);
15+
return 0;
16+
}
17+
18+
echo "cmd_smtp_server: ", $cmd[2], " ", $cmd[3], "\r\n";
19+
20+
esmtp_msa($cmd[2], (int)$cmd[3]);
21+
22+
return 0;
23+
}
24+
25+
function cmd_smtp_login($cmd)
26+
{
27+
if(count($cmd) < 4)
28+
return 0;
29+
30+
echo "cmd_smtp_login: ", $cmd[2], " ", $cmd[3], "\r\n";
31+
32+
esmtp_auth($cmd[2], $cmd[3]);
33+
34+
return 0;
35+
}
36+
37+
function cmd_smtp_from($cmd)
38+
{
39+
global $pid_pipe_data;
40+
41+
if(count($cmd) < 3)
42+
return 0;
43+
44+
$email = $cmd[2];
45+
$name = "";
46+
47+
pid_read($pid_pipe_data, $name);
48+
49+
echo "cmd_smtp_from: \"$name\" <$email>\r\n";
50+
51+
esmtp_account($email, $name);
52+
53+
return 0;
54+
}
55+
56+
function cmd_smtp_to($cmd)
57+
{
58+
global $smtp_to_email, $smtp_to_name;
59+
global $pid_pipe_data;
60+
61+
if(count($cmd) < 3)
62+
return 0;
63+
64+
$email = $cmd[2];
65+
$name = "";
66+
67+
pid_read($pid_pipe_data, $name);
68+
69+
echo "cmd_smtp_to: \"$name\" <$email>\r\n";
70+
71+
$smtp_to_email = $email;
72+
$smtp_to_name = $name;
73+
74+
return 0;
75+
}
76+
77+
function cmd_smtp_subject($cmd)
78+
{
79+
global $smtp_subject;
80+
global $pid_pipe_data;
81+
82+
pid_read($pid_pipe_data, $smtp_subject);
83+
84+
echo "cmd_smtp_subject: $smtp_subject\r\n";
85+
86+
return 0;
87+
}
88+
89+
function cmd_smtp_data($cmd)
90+
{
91+
global $smtp_data;
92+
global $pid_pipe_data;
93+
94+
if(count($cmd) > 2)
95+
{
96+
if($cmd[2] == "begin")
97+
{
98+
echo "cmd_smtp_data: begin\r\n";
99+
$smtp_data = "";
100+
return 0;
101+
}
102+
else
103+
return -EINVAL;
104+
}
105+
106+
$rbuf = "";
107+
$rlen = pid_read($pid_pipe_data, $rbuf);
108+
109+
echo "$rbuf";
110+
111+
if((strlen($smtp_data) + $rlen) <= MAX_DATA_LEN)
112+
$smtp_data .= $rbuf;
113+
114+
return 0;
115+
}
116+
117+
function cmd_smtp_send($cmd)
118+
{
119+
global $smtp_to_email, $smtp_to_name;
120+
global $smtp_subject, $smtp_data;
121+
122+
if(count($cmd) > 2)
123+
{
124+
if($cmd[2] == "ip6")
125+
$ip6 = true;
126+
else
127+
return -EINVAL;
128+
}
129+
else
130+
$ip6 = false;
131+
132+
esmtp_setup(UDP_ID_DNS, TCP_ID_SMTP, "", $ip6);
133+
esmtp_start($smtp_to_email, $smtp_to_name, $smtp_subject, $smtp_data);
134+
135+
return 0;
136+
}
137+
138+
function cmd_smtp_status($cmd)
139+
{
140+
global $pid_pipe_data;
141+
142+
$msg = esmtp_loop();
143+
144+
if($msg === false)
145+
return 0;
146+
else
147+
{
148+
if(!$msg)
149+
return 999;
150+
else
151+
return (int)$msg;
152+
}
153+
}
154+
155+
function cmd_smtp($cmd)
156+
{
157+
if(count($cmd) < 2)
158+
return -EINVAL;
159+
160+
switch($cmd[1])
161+
{
162+
case "server":
163+
return cmd_smtp_server($cmd);
164+
case "login":
165+
return cmd_smtp_login($cmd);
166+
case "from":
167+
return cmd_smtp_from($cmd);
168+
case "to":
169+
return cmd_smtp_to($cmd);
170+
case "subject":
171+
return cmd_smtp_subject($cmd);
172+
case "data":
173+
return cmd_smtp_data($cmd);
174+
case "send":
175+
return cmd_smtp_send($cmd);
176+
case "status":
177+
return cmd_smtp_status($cmd);
178+
default:
179+
return -EINVAL;
180+
}
181+
}
182+
183+
?>

config.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
define("PHPOC_PKG_INFO", "phpoc shield, 1.5.0,");
4+
define("UDP_ID_DNS", 5);
5+
define("TCP_ID_SMTP", 0);
6+
7+
define("WSM_BAUD" , 0x00);
8+
define("WSM_WIDTH" , 0x01);
9+
define("WSM_HEIGHT" , 0x02);
10+
11+
define("WSP_BAUD" , 0x10);
12+
define("WSP_SIZE" , 0x11);
13+
define("WSP_WIDTH" , 0x12);
14+
define("WSP_HEIGHT" , 0x13);
15+
define("WSP_SAMPLE" , 0x14);
16+
define("WSP_YSCALE" , 0x15);
17+
define("WSP_YMIN" , 0x16);
18+
define("WSP_YMAX" , 0x17);
19+
define("WSP_XTITLE" , 0x18);
20+
define("WSP_YTITLE" , 0x19);
21+
22+
define("WRP_WIDTH" , 0x20);
23+
define("WRP_BUTTON" , 0x21);
24+
25+
define("WRS_WIDTH" , 0x30);
26+
define("WRS_LEN" , 0x31);
27+
define("WRS_MAX" , 0x32);
28+
define("WRS_MIN" , 0x33);
29+
30+
define("WPD_WIDTH" , 0x40);
31+
define("WPD_HEIGHT" , 0x41);
32+
33+
?>

env_shield.ini

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
; user app env for PHPoC shield
2+
3+
; Web Serial Monitor
4+
0097.name = "Baud Rate"
5+
0097.min = 9600
6+
0097.data = 9600
7+
0097.max = 115200
8+
0097.list = "9600,19200,38400,57600,74880,115200"
9+
10+
0190.name = "Width"
11+
0190.min = 200
12+
0190.data = 400
13+
0190.max = 800
14+
15+
0290.name = "Height"
16+
0290.min = 200
17+
0290.data = 400
18+
0290.max = 800
19+
20+
03fd.data = "0097,0190,0290"
21+
03fd.name = "Serial Monitor"
22+
23+
; Web Serial Plotter
24+
1097.name = "Baud Rate"
25+
1097.min = 9600
26+
1097.data = 9600
27+
1097.max = 115200
28+
1097.list = "9600,19200,38400,57600,74880,115200"
29+
30+
1190.name = "Size Type"
31+
1190.data = 0
32+
1190.list = "Fixed Size:0,Full Screen:1"
33+
34+
1290.name = "Width"
35+
1290.min = 200
36+
1290.data = 400
37+
1290.max = 800
38+
39+
1390.name = "Height"
40+
1390.min = 200
41+
1390.data = 400
42+
1390.max = 800
43+
44+
1490.name = "Max Sample"
45+
1490.min = 100
46+
1490.data = 500
47+
1490.max = 10000
48+
49+
1590.name = "Y-Axis Auto Scale"
50+
1590.data = 1
51+
1590.list = "Fixed:0,Auto Scale:1"
52+
53+
1699.name = "Y-Fixed Min Bound"
54+
1699.data = -5
55+
56+
1799.name = "Y-Fixed Max Bound"
57+
1799.data = 5
58+
59+
1892.name = "X-Axis Title"
60+
1892.len = 32
61+
62+
1992.name = "Y-Axis Title"
63+
1992.len = 32
64+
65+
1afd.data = "1097,1190,1290,1390,1490,1590,1699,1799,1892,1992"
66+
1afd.name = "Serial Plotter"
67+
68+
; Web Remote Push
69+
2090.name = "Width"
70+
2090.min = 200
71+
2090.data = 400
72+
2090.max = 800
73+
74+
21fb.name = "Button"
75+
21fb.data = "A,B,C,D,E,F,G,H,I,,,"
76+
21fb.len = 108
77+
21fb.max = 12
78+
21fb.list = "A,B,C,D,E,F,G,H,I,J,K,L"
79+
80+
22fd.data = "2090,21fb"
81+
22fd.name = "Remote Push"
82+
83+
; Web Remote Slide
84+
3090.name = "Width"
85+
3090.min = 200
86+
3090.data = 400
87+
3090.max = 800
88+
89+
3190.name = "Length"
90+
3190.min = 200
91+
3190.data = 300
92+
3190.max = 800
93+
94+
3297.name = "Max value"
95+
3297.data = 100
96+
97+
3397.name = "Min value"
98+
3397.data = -100
99+
100+
34fd.data = "3090,3190,3297,3397"
101+
34fd.name = "Remote Slide"
102+
103+
; Web Remote Pad
104+
4090.name = "Width"
105+
4090.min = 200
106+
4090.data = 400
107+
4090.max = 800
108+
109+
4190.name = "Height"
110+
4190.min = 200
111+
4190.data = 400
112+
4190.max = 800
113+
114+
42fd.data = "4090,4190"
115+
42fd.name = "Remote Pad"
116+
117+
; user app env UI map
118+
fefe.data="03fd,1afd,22fd,34fd,42fd"
119+
fefe.name="PHPoC shield"
120+

env_shield.poc

1.33 KB
Binary file not shown.

0 commit comments

Comments
 (0)