Freedman v2
Dependencies: CameraC328 WizFi250Interface mbed-src
Fork of WizFi250TcpUdpExample by
main.cpp
00001 /* 00002 /* Copyright (C) 2014 Wiznet, 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 #include <stdio.h> 00021 #include "mbed.h" 00022 #include "WizFi250Interface.h" 00023 #include "CameraC328.h" 00024 00025 #define SECURE WizFi250::SEC_AUTO 00026 #define SSID "Ricky" 00027 #define PASS "ricky123" 00028 00029 //#define ECHO_SERVER_ADDRESS "192.168.0.2" 00030 //#define ECHO_SERVER_PORT 5000 00031 00032 /* CAMERA */ 00033 #define USE_JPEG_HIGH_RESOLUTION 2//1=80x64 <--- not working -_-;;, 2=160x128, 3=320x240, 4=640x480 00034 #define START "start" 00035 #define END "end" 00036 CameraC328 camera(PC_10, PC_11, CameraC328::Baud115200); 00037 00038 /* NETWORK */ 00039 #if defined(TARGET_FRDM_KL25Z) 00040 WizFi250Interface wizfi250(PTE0,PTE1,PTD5,PTD0,PTD4,NC,115200); 00041 #else 00042 WizFi250Interface wizfi250(D1,D0,D7,D8,PA_12,NC,115200); 00043 //Serial pc(USBTX, USBRX); 00044 //Serial pc2(PC_10,PC_11); 00045 #endif 00046 TCPSocketConnection Streaming; 00047 const char dest_ip[] = "192.168.0.2"; 00048 int dest_port = 1212; 00049 static char buf[128]; 00050 00051 00052 /* Function*/ 00053 void jpeg_callback(char *buf, size_t siz); 00054 void sync(void); 00055 void test_jpeg_snapshot_picture(void); 00056 00057 int main() 00058 { 00059 00060 wizfi250.init(); 00061 if ( wizfi250.connect(SECURE, SSID, PASS)) return -1; 00062 printf("IP Address is %s\r\n", wizfi250.getIPAddress()); 00063 00064 sync(); 00065 while (Streaming.connect(dest_ip, dest_port) < 0) { 00066 printf("Unable to connect to (%s) on port (%d)\r\n", dest_ip, dest_port); 00067 wait(1); 00068 } 00069 00070 while(1) 00071 { 00072 Streaming.send(START, sizeof(START)-1); 00073 test_jpeg_snapshot_picture(); 00074 Streaming.send(END, sizeof(END)-1); 00075 } 00076 00077 } 00078 00079 void jpeg_callback(char *buf, size_t siz) { 00080 //for (int i = 0; i < (int)siz; i++) { 00081 //fprintf(fp_jpeg, "%c", buf[i]); 00082 Streaming.send(buf, siz); 00083 //} 00084 } 00085 void sync(void) { 00086 CameraC328::ErrorNumber err = CameraC328::NoError; 00087 00088 err = camera.sync(); 00089 if (CameraC328::NoError == err) { 00090 printf("[ OK ] : CameraC328::sync\r\n"); 00091 } else { 00092 printf("[FAIL] : CameraC328::sync (Error=%02X)\r\n", (int)err); 00093 } 00094 } 00095 void test_jpeg_snapshot_picture() { 00096 CameraC328::ErrorNumber err = CameraC328::NoError; 00097 00098 #if (USE_JPEG_HIGH_RESOLUTION==1) 00099 err = camera.init(CameraC328::Jpeg, CameraC328::RawResolution80x60, CameraC328::JpegResolution80x64); 00100 #elif (USE_JPEG_HIGH_RESOLUTION==2) 00101 err = camera.init(CameraC328::Jpeg, CameraC328::RawResolution80x60, CameraC328::JpegResolution160x128); 00102 #elif (USE_JPEG_HIGH_RESOLUTION==3) 00103 err = camera.init(CameraC328::Jpeg, CameraC328::RawResolution80x60, CameraC328::JpegResolution320x240); 00104 #elif (USE_JPEG_HIGH_RESOLUTION==4) 00105 err = camera.init(CameraC328::Jpeg, CameraC328::RawResolution80x60, CameraC328::JpegResolution640x480); 00106 #endif 00107 if (CameraC328::NoError == err) { 00108 printf("[ OK ] : CameraC328::init\r\n"); 00109 } else { 00110 printf("[FAIL] : CameraC328::init (Error=%02X)\r\n", (int)err); 00111 } 00112 00113 err = camera.getJpegSnapshotPicture(jpeg_callback); 00114 if (CameraC328::NoError == err) { 00115 printf("[ OK ] : CameraC328::getJpegSnapshotPicture\r\n"); 00116 } else { 00117 printf("[FAIL] : CameraC328::getJpegSnapshotPicture (Error=%02X)\r\n", (int)err); 00118 } 00119 } 00120
Generated on Thu Jul 14 2022 01:47:07 by 1.7.2