Twilio phone calls by Dropbox phone book
Dependencies: EthernetInterface HTTPClient mbed-rtos mbed
main.cpp
00001 /* main.cpp */ 00002 /* Copyright (C) 2014 wolfSSL, MIT License 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 * furnished to do so, subject to the following conditions: 00009 * 00010 * The above copyright notice and this permission notice shall be included in all copies or 00011 * substantial portions of the Software. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 00021 #include "mbed.h" 00022 #include "EthernetInterface.h" 00023 #include "HTTPClient.h" 00024 00025 HTTPClient http; 00026 extern HTTPResult dropbox_get(const char *url, char * buff, int size) ; 00027 extern HTTPResult twilio_main(const char *phone) ; 00028 00029 static char Dropbox_URL[] = "https://www.dropbox.com/PHONE_LIST_FILE" ; 00030 00031 #define BUFF_SIZE 256 00032 static char buff[BUFF_SIZE] ; 00033 00034 void thread_main(void const *av) { 00035 dropbox_get(Dropbox_URL, buff, BUFF_SIZE) ; 00036 char *p = buff ; 00037 bool endflg = false ; 00038 for(int i = 0 ; i<BUFF_SIZE; i++) { 00039 if((p[i] == '\0') || (p[i] == '\n')) 00040 endflg = true ; 00041 if((p[i] == ',') || (p[i] == '\n') || (p[i] == '\0')){ 00042 p[i] = '\0' ; 00043 twilio_main(p) ; 00044 if(endflg)break ; 00045 p = &(p[i+1]) ; 00046 } 00047 } 00048 } 00049 00050 int main() 00051 { 00052 int ret ; 00053 void const *av ; 00054 00055 EthernetInterface eth; 00056 00057 printf("Dropbox Starting,...\n") ; 00058 ret = eth.init(); //Use DHCP 00059 while(1) { 00060 ret = eth.connect(); 00061 if(ret == 0)break ; 00062 } 00063 printf("IP = %s\n", eth.getIPAddress()); 00064 00065 //#define BOARD_FRDM_K64F 00066 #ifdef BOARD_FRDM_K64F 00067 #define STACK_SIZE 10000 00068 Thread t( thread_main, NULL, osPriorityNormal, STACK_SIZE); 00069 #else 00070 thread_main(av) ; 00071 #endif 00072 00073 while (true) { 00074 Thread::wait(1000); 00075 } 00076 }
Generated on Thu Jul 21 2022 16:16:45 by 1.7.2