php access
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
Fork of SimpleXively by
main.cpp@3:f17ce0127553, 2016-07-28 (annotated)
- Committer:
- thursday1024
- Date:
- Thu Jul 28 23:26:22 2016 +0000
- Revision:
- 3:f17ce0127553
- Parent:
- 1:3c8fcecce568
php access 2
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thursday1024 | 1:3c8fcecce568 | 1 | // php_acces main.cpp |
thursday1024 | 1:3c8fcecce568 | 2 | |
thursday1024 | 1:3c8fcecce568 | 3 | #include "mbed.h" |
wolfSSL | 0:a6ee4ada0d57 | 4 | #include "EthernetInterface.h" |
wolfSSL | 0:a6ee4ada0d57 | 5 | #include "HTTPClient.h" |
thursday1024 | 3:f17ce0127553 | 6 | #define BUFF_SIZE 128 |
wolfSSL | 0:a6ee4ada0d57 | 7 | |
thursday1024 | 1:3c8fcecce568 | 8 | extern void php_access_main( char *uri, char *ch_name, int* sp ); |
thursday1024 | 1:3c8fcecce568 | 9 | char php_uri[]="https://alpha.c.dendai.ac.jp/plot/save_data.php"; |
wolfSSL | 0:a6ee4ada0d57 | 10 | |
thursday1024 | 1:3c8fcecce568 | 11 | char ch_str[] ="ch13894"; |
wolfSSL | 0:a6ee4ada0d57 | 12 | |
wolfSSL | 0:a6ee4ada0d57 | 13 | extern HTTPClient http; |
wolfSSL | 0:a6ee4ada0d57 | 14 | EthernetInterface eth; |
wolfSSL | 0:a6ee4ada0d57 | 15 | |
thursday1024 | 1:3c8fcecce568 | 16 | static int speed=0; |
thursday1024 | 1:3c8fcecce568 | 17 | void thread_main( void const *av ){ |
thursday1024 | 1:3c8fcecce568 | 18 | char ch_name[BUFF_SIZE]; |
thursday1024 | 1:3c8fcecce568 | 19 | strcpy( ch_name, ch_str ); |
thursday1024 | 1:3c8fcecce568 | 20 | printf( "Channel Name:%s\n", ch_name ); |
thursday1024 | 1:3c8fcecce568 | 21 | |
thursday1024 | 1:3c8fcecce568 | 22 | php_access_main( php_uri, ch_name, &speed ); // |
thursday1024 | 1:3c8fcecce568 | 23 | |
thursday1024 | 1:3c8fcecce568 | 24 | while(true) Thread::wait(1000); |
thursday1024 | 1:3c8fcecce568 | 25 | } |
thursday1024 | 1:3c8fcecce568 | 26 | |
thursday1024 | 1:3c8fcecce568 | 27 | // memo |
thursday1024 | 1:3c8fcecce568 | 28 | // R-LED -> LED1; G-LED -> LED2; B-LED -> LED3; |
thursday1024 | 1:3c8fcecce568 | 29 | // sw3 -> PTA4; sw2 -> PTC6; |
thursday1024 | 1:3c8fcecce568 | 30 | |
thursday1024 | 1:3c8fcecce568 | 31 | DigitalOut my_LED0(LED1); |
thursday1024 | 1:3c8fcecce568 | 32 | DigitalOut my_LED1(LED3); |
thursday1024 | 1:3c8fcecce568 | 33 | DigitalOut my_LED2(LED2); |
thursday1024 | 1:3c8fcecce568 | 34 | DigitalIn my_sw0(PTA4); |
thursday1024 | 1:3c8fcecce568 | 35 | DigitalIn my_sw1(PTC6); |
wolfSSL | 0:a6ee4ada0d57 | 36 | |
thursday1024 | 1:3c8fcecce568 | 37 | int main() { |
thursday1024 | 1:3c8fcecce568 | 38 | my_LED0=1; |
thursday1024 | 1:3c8fcecce568 | 39 | my_LED1=1; |
thursday1024 | 1:3c8fcecce568 | 40 | Timer t; |
thursday1024 | 1:3c8fcecce568 | 41 | t.start(); |
wolfSSL | 0:a6ee4ada0d57 | 42 | |
thursday1024 | 1:3c8fcecce568 | 43 | int ret = eth.init(); //Use DHCP |
thursday1024 | 1:3c8fcecce568 | 44 | printf( "php_test Starting,...\n" ) ; |
thursday1024 | 1:3c8fcecce568 | 45 | while(1) { |
thursday1024 | 1:3c8fcecce568 | 46 | ret = eth.connect(); |
thursday1024 | 1:3c8fcecce568 | 47 | if( ret==0 )break ; // DHCP OK |
thursday1024 | 1:3c8fcecce568 | 48 | Thread::wait( 100 ); |
wolfSSL | 0:a6ee4ada0d57 | 49 | } |
thursday1024 | 1:3c8fcecce568 | 50 | t.stop(); |
thursday1024 | 1:3c8fcecce568 | 51 | srand(t.read_ms()); |
thursday1024 | 1:3c8fcecce568 | 52 | |
thursday1024 | 1:3c8fcecce568 | 53 | printf( "IP = %s\n", eth.getIPAddress() ); |
wolfSSL | 0:a6ee4ada0d57 | 54 | |
thursday1024 | 1:3c8fcecce568 | 55 | #define STACK_SIZE 20000 |
thursday1024 | 1:3c8fcecce568 | 56 | Thread thr( thread_main, NULL, osPriorityNormal, STACK_SIZE ); |
thursday1024 | 1:3c8fcecce568 | 57 | speed=0; |
thursday1024 | 1:3c8fcecce568 | 58 | int i=0; |
thursday1024 | 1:3c8fcecce568 | 59 | while(true){ |
thursday1024 | 1:3c8fcecce568 | 60 | if(!my_sw0 && speed<=0)speed++; |
thursday1024 | 1:3c8fcecce568 | 61 | if(!my_sw1 && speed>=0)speed--; |
thursday1024 | 1:3c8fcecce568 | 62 | if(speed>0 ){my_LED0=0;my_LED1=1;my_LED2=1;} |
thursday1024 | 1:3c8fcecce568 | 63 | if(speed<0 ){my_LED0=1;my_LED1=0;my_LED2=1;} |
thursday1024 | 1:3c8fcecce568 | 64 | if(speed==0){my_LED0=1;my_LED1=1;my_LED2=0;} |
thursday1024 | 1:3c8fcecce568 | 65 | speed = (rand()%3)-1; |
wolfSSL | 0:a6ee4ada0d57 | 66 | Thread::wait(1000); |
thursday1024 | 1:3c8fcecce568 | 67 | i++; |
wolfSSL | 0:a6ee4ada0d57 | 68 | } |
wolfSSL | 0:a6ee4ada0d57 | 69 | } |
wolfSSL | 0:a6ee4ada0d57 | 70 |