Skip to content

Commit 766e778

Browse files
committed
2020.07.07. psp_2.2.2
- lib/sc_envs.php > Supports APP ENV > Supports dump ENV - lib/sc_envu.php > Add 0xFF to the trailing character that needs to be removed - lib/sd_340.php > Supports P4M-400 - lib/sn_mysql.php > Add a exception for server greeting error - lib/sn_smtp.php > Bug fix | fixed TCP local port number - lib/sn_esmtp.php > Bug fix | fixed TCP local port number > Change ssl client version : fixed to TLS v1.0 -> variable (TLS v1.0 ~ v1.2[default]) - lib/beta/sn_http_b1.php > Change ssl client version : fixed to TLS v1.0 -> variable (TLS v1.0 ~ v1.2[default]) - example/net/01.php_task/email/task0.php > Additional debugging messages about mail delivery failure - example/net/01.php_task/http_get/task0.php > Change peer hostname : www.google.com -> example.phpoc.com - example/net/01.php_task/tcp0_echo_ac/task0.php > Add debugging messages about TCP rcvd/echo data - example/net/01.php_task/tcpn_echo_ac/task0.php > Add debugging messages about TCP rcvd/echo data - example/net/02.html_text/setup/ > Disable Wi-Fi settings for the product supports Ethernet only, ex) P4S-341 > Remove an Ad-Hoc option for WLAN Topology > Change Sollae homepage URL : www.sollae.co.kr -> www.eztcp.com - example/p4s/05.html5_graphics/02.adc_light_sensor/ > Fixed websocket path typo - new beta library > sc_cps_b1.php > sn_http_b2.php new version of sn_http_b1.php > sn_mqtt_b1.php supports mqtt protocol > sn_dfu_b1.php dfu pxm is required to use this library > sc_modbus_b1.php supports modbus (TCP/RTU/ASCII) protocol xuart pxm is required to use this library - new examples > example/beta/mqtt/publisher/ > example/beta/mqtt/subscriber/ > example/net/01.php_task/https_get/ > example/p4m/01.php_task/00.hello/ > example/p4m/01.php_task/01.uio_buzzer/ > example/p4m/01.php_task/01.uio_ob_led/ > example/p4m/01.php_task/01.uio_touch_sensor/ > example/p4m/01.php_task/02.adc_light_sensor/ > example/p4m/01.php_task/02.adc_rotary_angle/ > example/p4m/01.php_task/03.ht_pwm_servo/ > example/p4m/01.php_task/03.ht_ultrasonic/ > example/p4m/01.php_task/06.uart_hello/ > example/p4m/01.php_task/08.pes_2401_blink_output > example/p4m/01.php_task/08.pes_2402_get_input > example/p4m/01.php_task/08.pes_2405_move_fast > example/p4m/01.php_task/08.pes_2405_move_slow > example/p4m/02.html_text/00.hello/ > example/p4m/02.html_text/01.uio_buzzer/ > example/p4m/02.html_text/01.uio_ob_led/ > example/p4m/02.html_text/01.uio_touch_sensor/ > example/p4m/02.html_text/02.adc_light_sensor/ > example/p4m/02.html_text/02.adc_rotary_angle/ > example/p4m/02.html_text/03.ht_pwm_servo/ > example/p4m/02.html_text/03.ht_ultrasonic/ > example/p4m/03.html_image/00.hello/ > example/p4m/03.html_image/01.uio_buzzer/ > example/p4m/03.html_image/01.uio_ob_led/ > example/p4m/03.html_image/01.uio_touch_sensor/ > example/p4m/03.html_image/02.adc_light_sensor/ > example/p4m/03.html_image/02.adc_rotary_angle/ > example/p4m/03.html_image/03.ht_pwm_servo/ > example/p4m/03.html_image/03.ht_ultrasonic/ > example/p4m/03.html_image/08.pes_2401_push_output > example/p4m/04.html5_text/00.hello/ > example/p4m/04.html5_text/01.uio_touch_sensor/ > example/p4m/04.html5_text/02.adc_light_sensor/ > example/p4m/04.html5_text/02.adc_rotary_angle/ > example/p4m/04.html5_text/03.ht_ultrasonic/ > example/p4m/05.html5_graphics/00.hello/ > example/p4m/05.html5_graphics/01.uio_buzzer/ > example/p4m/05.html5_graphics/01.uio_ob_led/ > example/p4m/05.html5_graphics/02.adc_light_sensor/ > example/p4m/05.html5_graphics/02.adc_rotary_angle/ > example/p4m/05.html5_graphics/03.ht_pwm_servo/ > example/p4m/05.html5_graphics/08.pes_2404_pos_rpm > example/p4m/05.html5_graphics/08.pes_2405_touch_rotate
1 parent bcfb031 commit 766e778

File tree

130 files changed

+8288
-102
lines changed

Some content is hidden

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

130 files changed

+8288
-102
lines changed

README.md

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,22 @@
22
PHPoC source codes for basic libraries and examples
33

44
## Libraries
5+
* sc_cps_b1.php (*BETA*) (*added*)
56
* sc_envs.php
67
* sc_envu.php
8+
* sc_modbus_b1.php (*BETA*) (*added*)
79
* sd_101.php
810
* sd_104.php
911
* sd_204.php
1012
* sd_340.php
1113
* sd_spc.php
14+
* sn_dfu_b1.php (*BETA*) (*added*)
1215
* sn_dns.php
1316
* sn_esmtp.php
1417
* sn_http_b1.php (*BETA*)
18+
* sn_http_b2.php (*BETA*) (*added*)
1519
* sn_json_b1.php (*BETA*)
20+
* sn_mqtt_b1.php (*BETA*) (*added*)
1621
* sn_mysql.php
1722
* sn_smtp.php
1823
* sn_sntp_b1.php (*BETA*)
@@ -21,12 +26,18 @@ PHPoC source codes for basic libraries and examples
2126
* sn_thingspeak_b1.php (*BETA*)
2227

2328
## Examples
29+
### beta
30+
#### mqtt
31+
* publisher (*added*)
32+
* subscriber (*added*)
33+
2434
### net
2535
#### 1. php_task
2636
* dns_lookup
2737
* email
2838
* email_msa
2939
* http_get
40+
* https_get (*added*)
3041
* mysql_insert
3142
* mysql_update
3243
* tcp0_echo_ac
@@ -35,6 +46,60 @@ PHPoC source codes for basic libraries and examples
3546
#### 2. html_text
3647
* setup
3748

49+
### p4m
50+
#### 1. php_task
51+
* hello (*added*)
52+
* uio_buzzer (*added*)
53+
* uio_ob_led (*added*)
54+
* uio_touch_sensor (*added*)
55+
* adc_light_sensor (*added*)
56+
* adc_rotary_angle (*added*)
57+
* ht_pwm_servo (*added*)
58+
* ht_ultrasonic (*added*)
59+
* uart_hello (*added*)
60+
* pes_2401_blink_outpu (*added*)t
61+
* pes_2402_get_input (*added*)
62+
* pes_2405_move_fast (*added*)
63+
* pes_2405_move_slow (*added*)
64+
65+
#### 2. html_text
66+
* hello (*added*)
67+
* uio_buzzer (*added*)
68+
* uio_ob_led (*added*)
69+
* uio_touch_sensor (*added*)
70+
* adc_light_sensor (*added*)
71+
* adc_rotary_angle (*added*)
72+
* ht_pwm_servo (*added*)
73+
* ht_ultrasonic (*added*)
74+
75+
#### 3. html_image
76+
* hello (*added*)
77+
* uio_buzzer (*added*)
78+
* uio_ob_led (*added*)
79+
* uio_touch_sensor (*added*)
80+
* adc_light_sensor (*added*)
81+
* adc_rotary_angle (*added*)
82+
* ht_pwm_servo (*added*)
83+
* ht_ultrasonic (*added*)
84+
* pes_2401_push_output (*added*)
85+
86+
#### 4. html5_text
87+
* hello (*added*)
88+
* uio_touch_sensor (*added*)
89+
* adc_light_sensor (*added*)
90+
* adc_rotary_angle (*added*)
91+
* ht_ultrasonic (*added*)
92+
93+
#### 5. html5_graphics
94+
* hello (*added*)
95+
* uio_buzzer (*added*)
96+
* uio_ob_led (*added*)
97+
* adc_light_sensor (*added*)
98+
* adc_rotary_angle (*added*)
99+
* ht_pwm_servo (*added*)
100+
* pes_2404_pos_rpm (*added*)
101+
* pes_2405_touch_rotate (*added*)
102+
38103
### p4s
39104
#### 1. php_task
40105
* hello
@@ -46,10 +111,10 @@ PHPoC source codes for basic libraries and examples
46111
* ht_pwm_servo
47112
* ht_ultrasonic
48113
* uart_hello
49-
* pes_2401_blink_output (*added*)
50-
* pes_2402_get_input (*added*)
51-
* pes_2405_move_fast (*added*)
52-
* pes_2405_move_slow (*added*)
114+
* pes_2401_blink_output
115+
* pes_2402_get_input
116+
* pes_2405_move_fast
117+
* pes_2405_move_slow
53118

54119
#### 2. html_text
55120
* hello
@@ -70,7 +135,7 @@ PHPoC source codes for basic libraries and examples
70135
* adc_rotary_angle
71136
* ht_pwm_servo
72137
* ht_ultrasonic
73-
* pes_2401_push_output (*added*)
138+
* pes_2401_push_output
74139

75140
#### 4. html5_text
76141
* hello
@@ -86,8 +151,8 @@ PHPoC source codes for basic libraries and examples
86151
* adc_light_sensor
87152
* adc_rotary_angle
88153
* ht_pwm_servo
89-
* pes_2404_pos_rpm (*added*)
90-
* pes_2405_touch_rotate (*added*)
154+
* pes_2404_pos_rpm
155+
* pes_2405_touch_rotate
91156

92157
### pbh
93158
#### 1. php_task
@@ -99,4 +164,4 @@ PHPoC source codes for basic libraries and examples
99164
* 204
100165

101166
## References
102-
* [PSP Library Reference](http://www.phpoc.com/support/manual/psp_library_reference/)
167+
* [PSP Library Reference] (https://www.phpoc.com/support/manual/psp_library_reference/)

example/beta/mqtt/publisher/init.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
system("php publisher.php");
4+
5+
?>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
include_once "/lib/sn_dns.php";
4+
include_once "/lib/sn_mqtt_b1.php";
5+
6+
$host_name = "xxxxxxxxxxxxxx.iot.ap-northeast-2.amazonaws.com";
7+
//$host_name = "iot.eclipse.org";
8+
//$host_name = "broker.hivemq.com";
9+
//$host_name = "broker.mqttdashboard.com";
10+
//$host_name = "[192.168.0.3]";
11+
12+
//$port = 1883;
13+
$port = 8883;
14+
15+
mqtt_setup(0, 0, $host_name, $port);
16+
17+
//mqtt_auth(0, "your_username", "your_password");
18+
19+
mqtt_client(0, "my_client_id_pub", MQTT_VER_3_1_1);
20+
21+
//mqtt_will(0, "will_topic", "i'll be back", MQTT_QOS1);
22+
//mqtt_will(0, "will_topic", "i'll be back", MQTT_QOS2, MQTT_WILL_RETAIN);
23+
24+
//mqtt_connect(0);
25+
//mqtt_connect(0, MQTT_CONN_SSL);
26+
//mqtt_connect(0, MQTT_CONN_CLEAN);
27+
mqtt_connect(0, MQTT_CONN_SSL | MQTT_CONN_CLEAN);
28+
29+
$recv_topic = "";
30+
$recv_content = "";
31+
$recv_retain = 0;
32+
33+
while(1)
34+
{
35+
if(mqtt_state(0) == MQTT_DISCONNECTED)
36+
{
37+
while(mqtt_reconnect(0) == false)
38+
sleep(2);
39+
}
40+
41+
if(mqtt_state(0) == MQTT_CONNECTED)
42+
{
43+
mqtt_publish(0, '$aws/things/myled/shadow/update', "Message From PHPoC: Hello World!", MQTT_QOS0);
44+
mqtt_publish(0, '$aws/things/mydoor/shadow/update', "Message From PHPoC: Hello World!", MQTT_QOS1);
45+
//mqtt_publish(0, '$aws/things/mydoor/shadow/update', "Message From PHPoC: Hello World!", MQTT_QOS1, MQTT_PUB_RETAIN);
46+
sleep(1);
47+
}
48+
49+
if(mqtt_loop(0))
50+
{
51+
mqtt_recv(0, $recv_topic, $recv_content, $recv_retain);
52+
53+
//TODO , procees the received publish packet here
54+
if($recv_retain == 1)
55+
echo "<<a stale message\r\n";
56+
57+
echo "<<topic:$recv_topic\r\n";
58+
echo "<<content: $recv_content\r\n";
59+
}
60+
}
61+
62+
mqtt_disconnect(0);
63+
64+
?>

example/beta/mqtt/subscriber/init.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
system("php subscriber.php");
4+
5+
?>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
include_once "/lib/sn_dns.php";
4+
include_once "/lib/sn_mqtt_b1.php";
5+
6+
$host_name = "xxxxxxxxxxxxxx.iot.ap-northeast-2.amazonaws.com";
7+
//$host_name = "iot.eclipse.org";
8+
//$host_name = "broker.hivemq.com";
9+
//$host_name = "broker.mqttdashboard.com";
10+
//$host_name = "[192.168.0.3]";
11+
12+
//$port = 1883;
13+
$port = 8883;
14+
15+
mqtt_setup(0, 0, $host_name, $port);
16+
17+
//mqtt_auth(0, "your_username", "your_password");
18+
19+
mqtt_client(0, "my_client_sub", MQTT_VER_3_1_1);
20+
21+
//mqtt_will(0, "will_topic", "i'll be back", MQTT_QOS1);
22+
//mqtt_will(0, "will_topic", "i'll be back", MQTT_QOS2, MQTT_WILL_RETAIN);
23+
24+
//mqtt_connect(0);
25+
//mqtt_connect(0, MQTT_CONN_SSL);
26+
//mqtt_connect(0, MQTT_CONN_CLEAN);
27+
mqtt_connect(0, MQTT_CONN_SSL | MQTT_CONN_CLEAN);
28+
29+
if(mqtt_state(0) == MQTT_CONNECTED)
30+
{
31+
mqtt_subscribe(0, '$aws/things/myled/shadow/update', 1);
32+
mqtt_subscribe(0, '$aws/things/mydoor/shadow/update', 0);
33+
//mqtt_subscribe(0, "will_topic", 0);
34+
}
35+
36+
$recv_topic = "";
37+
$recv_content = "";
38+
$recv_retain = 0;
39+
40+
while(1)
41+
{
42+
if(mqtt_state(0) == MQTT_DISCONNECTED)
43+
{
44+
while(mqtt_reconnect(0) == false)
45+
sleep(2);
46+
}
47+
48+
if(mqtt_loop(0))
49+
{
50+
mqtt_recv(0, $recv_topic, $recv_content, $recv_retain);
51+
52+
//TODO , procees the received publish packet here
53+
if($recv_retain == 1)
54+
echo "<<a stale message\r\n";
55+
56+
echo "<<topic:$recv_topic\r\n";
57+
echo "<<content: $recv_content\r\n";
58+
}
59+
}
60+
61+
mqtt_unsubscribe(0, '$aws/things/mydoor/shadow/update');
62+
mqtt_disconnect(0);
63+
64+
?>

example/net/01.php_task/email/task0.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@
1818
$msg = smtp_send("to_id@to_domain.com", "to_name", $subject, $message);
1919

2020
if($msg == "221")
21-
echo "send email successful\r\n";
21+
echo "Send email successful\r\n";
2222
else
23-
echo "send email failed\r\n";
23+
{
24+
echo "Send email failed: ";
25+
echo "Some receiving mail servers may check the 'Reverse DNS Mismatch' as an indication of a possible spam source. ";
26+
echo "If the hostname did not match the reverse lookup (PTR) for the IP Address, ";
27+
echo "the server may move the email to the spam mailbox or reject it without notice\r\n";
28+
}
2429

2530
?>

example/net/01.php_task/http_get/task0.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55

66
include_once "/lib/sn_dns.php";
77

8-
echo "PHPoC example : get web page from www server\r\n";
8+
echo "PHPoC example : get web page from http server\r\n";
9+
10+
$host_name = "example.phpoc.com";
11+
$host_port = 80;
912

10-
$host_name = "www.google.com";
1113
$host_addr = dns_lookup($host_name, RR_A);
1214

1315
if($host_addr == $host_name)
1416
exit "$host_name : Not Found\r\n";
1517

1618
$tcp0_pid = pid_open("/mmap/tcp0");
19+
pid_bind($tcp0_pid, "", 0);
1720

18-
echo "connect to $host_addr:80...";
21+
echo "connect to $host_addr:$host_port...";
1922

20-
pid_connect($tcp0_pid, $host_addr, 80);
23+
pid_connect($tcp0_pid, $host_addr, $host_port);
2124

2225
for(;;)
2326
{
@@ -35,6 +38,9 @@
3538

3639
echo "connected\r\n";
3740

41+
//$http_req = "GET /request_method/ HTTP/1.1\r\n";
42+
//$http_req = "GET /request_header/ HTTP/1.1\r\n";
43+
//$http_req = "GET /asciilogo.txt HTTP/1.1\r\n";
3844
$http_req = "GET / HTTP/1.1\r\n";
3945
$http_req .= "Host: $host_name\r\n";
4046
$http_req .= "Connection: closed\r\n";
@@ -56,7 +62,7 @@
5662
break;
5763
}
5864

59-
echo "connection closed\r\n";
65+
echo "\r\nconnection closed\r\n";
6066

6167
pid_close($tcp0_pid);
6268

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
system("php task0.php");
4+
5+
?>

0 commit comments

Comments
 (0)