Usage example, Xively with wolfSSL
Dependencies: EthernetInterface HTTPClient SDFileSystem mbed-rtos mbed wolfSSL
Fork of SimpleXively by
main.cpp
- Committer:
- wolfSSL
- Date:
- 2015-07-21
- Revision:
- 2:74161080023f
- Parent:
- 1:60e6225ef3e5
File content as of revision 2:74161080023f:
/* main.cpp * * Copyright (C) 2006-2014 wolfSSL Inc. * * This file is part of CyaSSL. * * CyaSSL is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * CyaSSL is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ #include "mbed.h" #include "EthernetInterface.h" #include "HTTPClient.h" #include <SDFileSystem.h> SDFileSystem sdCard(PTE3, PTE1, PTE2, PTE4, "sd"); #define BUFFSIZE (50+1) extern void xively_main(char *feed_id, char *api_key, char *ch_name) ; extern HTTPClient http; EthernetInterface eth; void thread_main(void const *av) { int i ; char ch_name[BUFFSIZE] ; FILE *fp ; char id[BUFFSIZE], key[BUFFSIZE] ; fp = fopen("/sd/XivelyKey.txt", "r"); if (fp == NULL) { printf("Cannot open \"XivelyKey.txt\"\n") ; return ; } fgets(id, sizeof(id), fp) ; if((id[strlen(id)-2] == '\n')||(id[strlen(id)-2] == '\r'))id[strlen(id)-2] = '\0' ; fgets(key, sizeof(key), fp) ; if((key[strlen(key)-2] == '\n')||(key[strlen(key)-2] == '\r'))key[strlen(key)-2] = '\0' ; printf("ID=%s\nKey=%s\n",id, key) ; printf("Channel Name:") ; for(i=0; i<BUFFSIZE; i++) { if((ch_name[i] = getchar()) == '\r') { ch_name[i] = '\0' ; putchar('\n') ; break ; } else putchar(ch_name[i]) ; } xively_main(id, key, ch_name) ; while (true) { Thread::wait(1000); } } int main() { int ret ; ret = eth.init(); //Use DHCP printf("Xively Starting,...\n") ; while(1) { ret = eth.connect(); if(ret == 0)break ; Thread::wait(100); } printf("IP = %s\n", eth.getIPAddress()); #define STACK_SIZE 20000 Thread t( thread_main, NULL, osPriorityNormal, STACK_SIZE); while(1) Thread::wait(1000) ; }