Using Camera module, FTP Client on WIZwiki-W7500, send the image data to FTP Server.

Dependencies:   CameraC328 SDFileSystem WIZnetInterface mbed-src

Fork of Camera_FTP_WIZwiki-W7500 by Ricky Kwon

Prerequisite

This example send the image data acquired from the camera to an FTP Server.

To implement this function, you need a Platform board, network Interface board, camera module.

Available camera modules are C328, LJ-DSC02. Because the cameras listed above all have similar internal protocols.

This example uses LJ-DSC02.

  • WIZwiki-W7500 from WIZnet (Platform board and Ethernet I/F board)
  • LJ-DSC02 (Camera module)
  • FTP Server(AL FTP)
  • Micro SD Card

Hardware Configuration

/media/uploads/Ricky_Kwon/camera.png

  • connect Ethernet Cable & USB Cable
  • connect Camera module

Software

Init FTP Server information

static char ID[]={"abc"};                   //Set FTPServer Login ID
static char PASSWORD[]={"123"};             //Set FTPServer Login Password
const char ftpServer_control_ip_addr[] = "192.168.1.2";

Caution

Must fix FTP server ip, id, pass

Revision:
1:7d428f360a0a
Parent:
0:27fe09e9f405
Child:
2:c469227cb913
--- a/main.cpp	Tue Jul 21 17:33:35 2015 +0000
+++ b/main.cpp	Tue Jul 21 23:52:52 2015 +0000
@@ -58,12 +58,12 @@
 char gMsgBuf[10];
 int User_Keyboard_MSG_Cnt;
 /* CAMERA */
-static const int CAPTURE_FRAMES = 1;
 static FILE *fp_jpeg;
 char fname[32];
 char fname_server[16];
+char fnamecnt=0;
 CameraC328 camera(PA_13, PA_14, CameraC328::Baud115200);
-/* Fuction*/ 
+/* Function*/ 
 char* User_Keyboard_MSG(void);
 int pportc(char * arg);
 void jpeg_callback(char *buf, size_t siz);
@@ -73,8 +73,6 @@
 int main() {
 
     char Msg_c;
-    int size;
-    int remain_datasize;
     int remain_filesize;
     int send_byte;
     
@@ -101,7 +99,8 @@
     //while 1
     while(true)
     {
-        if(pc.getc()==0x31){
+        Msg_c = pc.getc();
+        if(Msg_c==0x31){
             
             test_jpeg_snapshot_picture();
             ftpclientrun = true;
@@ -132,17 +131,15 @@
                     int n = FTP_CONTROL_SOCK.receive(buf, sizeof(buf));
                     if (n <= 0) break;
                     buf[n] = '\0';
-                    pc.printf("Received message from server: '%s' \n", buf);
+                    pc.printf("\r\nReceived message from server: '%s'\r\n", buf);
                     
                     //buf if
                     if (!strncmp(buf, "220", 3)){
-                        pc.printf("\r\nInput your User ID > ");
                         FTP_CONTROL_SOCK.send(USER, sizeof(USER)-1);
                         //FTP_CONTROL_SOCK.send(gMsgBuf, User_Keyboard_MSG_Cnt-1);
                         FTP_CONTROL_SOCK.send(END, sizeof(END)-1);
                     }
                     else if(!strncmp(buf, "331", 3)){
-                        pc.printf("\r\nInput your Password > ");
                         FTP_CONTROL_SOCK.send(PASS, sizeof(PASS)-1);
                         //FTP_CONTROL_SOCK.send(gMsgBuf, User_Keyboard_MSG_Cnt-1);
                         FTP_CONTROL_SOCK.send(END, sizeof(END)-1);        
@@ -275,9 +272,9 @@
 
     err = camera.sync();
     if (CameraC328::NoError == err) {
-        printf("[ OK ] : CameraC328::sync\n");
+        printf("[ OK ] : CameraC328::sync\r\n");
     } else {
-        printf("[FAIL] : CameraC328::sync (Error=%02X)\n", (int)err);
+        printf("[FAIL] : CameraC328::sync (Error=%02X)\r\n", (int)err);
     }
 }
 void test_jpeg_snapshot_picture(void) {
@@ -289,25 +286,26 @@
     err = camera.init(CameraC328::Jpeg, CameraC328::RawResolution80x60, CameraC328::JpegResolution320x240);
 #endif
     if (CameraC328::NoError == err) {
-        printf("[ OK ] : CameraC328::init\n");
+        printf("[ OK ] : CameraC328::init\r\n");
     } else {
-        printf("[FAIL] : CameraC328::init (Error=%02X)\n", (int)err);
+        printf("[FAIL] : CameraC328::init (Error=%02X)\r\n", (int)err);
     }
 
-    for (int i = 0; i < CAPTURE_FRAMES; i++) {
-        snprintf(fname, sizeof(fname), "/sd/jpss%04d.jpg", i);
-        for(int i = 0; i < 12; i++){
-           fname_server[0+i] = fname[4+i]; 
-        }
-        fp_jpeg = fopen(fname, "w");
+
+    snprintf(fname, sizeof(fname), "/sd/jpss%04d.jpg", fnamecnt);
+    fnamecnt++;
+    for(int i = 0; i < 12; i++){
+       fname_server[0+i] = fname[4+i]; 
+    }
+    fp_jpeg = fopen(fname, "w");
 
-        err = camera.getJpegSnapshotPicture(jpeg_callback);
-        if (CameraC328::NoError == err) {
-            printf("[ OK ] : CameraC328::getJpegSnapshotPicture\n");
-        } else {
-            printf("[FAIL] : CameraC328::getJpegSnapshotPicture (Error=%02X)\n", (int)err);
-        }
+    err = camera.getJpegSnapshotPicture(jpeg_callback);
+    if (CameraC328::NoError == err) {
+        printf("[ OK ] : CameraC328::getJpegSnapshotPicture\r\n");
+    } else {
+        printf("[FAIL] : CameraC328::getJpegSnapshotPicture (Error=%02X)\r\n", (int)err);
+    }
 
-        fclose(fp_jpeg);
-    }
+    fclose(fp_jpeg);
+
 }
\ No newline at end of file