Change to wifi AP mode. SSID "GR-PEACH_1", PSK "12345"

Dependencies:   DhcpServer EthernetInterface FATFileSystem GR-PEACH_WlanBP3595AP GR-PEACH_video GraphicsFramework HttpServer_snapshot R_BSP mbed-rpc mbed-rtos mbed

Fork of GR-Boards_WebCamera by Renesas

Committer:
dkato
Date:
Fri Oct 09 10:11:57 2015 +0000
Revision:
2:82a6d79d05f0
Parent:
1:ebff3aeb40a0
Child:
4:487e6c5bea1e
The IP address is acquired from DHCP Server.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:c5448e500c90 1 #include "mbed.h"
dkato 0:c5448e500c90 2 #include "DisplayBace.h"
dkato 0:c5448e500c90 3 #include "rtos.h"
dkato 0:c5448e500c90 4 #include "JPEG_Converter.h"
dkato 0:c5448e500c90 5 #include "EthernetInterface.h"
dkato 0:c5448e500c90 6 #include "HTTPServer.h"
dkato 0:c5448e500c90 7 #include "mbed_rpc.h"
dkato 0:c5448e500c90 8 #include "RomRamFileSystem.h"
dkato 0:c5448e500c90 9 #include "file_table.h" //Binary data of web pages
dkato 0:c5448e500c90 10
dkato 0:c5448e500c90 11 RomRamFileSystem romramfs("romram");
dkato 0:c5448e500c90 12 EthernetInterface eth;
dkato 0:c5448e500c90 13
dkato 0:c5448e500c90 14 #define VIDEO_CVBS (0) /* Analog Video Signal */
dkato 0:c5448e500c90 15 #define VIDEO_CMOS_CAMERA (1) /* Digital Video Signal */
dkato 0:c5448e500c90 16 #define VIDEO_YCBCR422 (0)
dkato 0:c5448e500c90 17 #define VIDEO_RGB888 (1)
dkato 0:c5448e500c90 18 #define VIDEO_RGB565 (2)
dkato 0:c5448e500c90 19
dkato 0:c5448e500c90 20 /**** User Selection *********/
dkato 0:c5448e500c90 21 #define VIDEO_INPUT_METHOD (VIDEO_CMOS_CAMERA) /* Select VIDEO_CVBS or VIDEO_CMOS_CAMERA */
dkato 0:c5448e500c90 22 #define VIDEO_INPUT_FORMAT (VIDEO_YCBCR422) /* Select VIDEO_YCBCR422 or VIDEO_RGB888 or VIDEO_RGB565 */
dkato 0:c5448e500c90 23 #define USE_VIDEO_CH (0) /* Select 0 or 1 If selecting VIDEO_CMOS_CAMERA, should be 0.) */
dkato 0:c5448e500c90 24 #define VIDEO_PAL (0) /* Select 0(NTSC) or 1(PAL) If selecting VIDEO_CVBS, this parameter is not referenced.) */
dkato 0:c5448e500c90 25 /*****************************/
dkato 0:c5448e500c90 26
dkato 0:c5448e500c90 27 #if USE_VIDEO_CH == (0)
dkato 0:c5448e500c90 28 #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_0)
dkato 0:c5448e500c90 29 #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S0_VFIELD)
dkato 0:c5448e500c90 30 #else
dkato 0:c5448e500c90 31 #define VIDEO_INPUT_CH (DisplayBase::VIDEO_INPUT_CHANNEL_1)
dkato 0:c5448e500c90 32 #define VIDEO_INT_TYPE (DisplayBase::INT_TYPE_S1_VFIELD)
dkato 0:c5448e500c90 33 #endif
dkato 0:c5448e500c90 34
dkato 0:c5448e500c90 35 #if ( VIDEO_INPUT_FORMAT == VIDEO_YCBCR422 || VIDEO_INPUT_FORMAT == VIDEO_RGB565 )
dkato 0:c5448e500c90 36 #define DATA_SIZE_PER_PIC (2u)
dkato 0:c5448e500c90 37 #else
dkato 0:c5448e500c90 38 #define DATA_SIZE_PER_PIC (4u)
dkato 0:c5448e500c90 39 #endif
dkato 0:c5448e500c90 40
dkato 0:c5448e500c90 41 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
dkato 0:c5448e500c90 42 in accordance with the frame buffer burst transfer mode. */
dkato 0:c5448e500c90 43 #define PIXEL_HW (320u) /* QVGA */
dkato 0:c5448e500c90 44 #define PIXEL_VW (240u) /* QVGA */
dkato 0:c5448e500c90 45
dkato 0:c5448e500c90 46 #define VIDEO_BUFFER_STRIDE (((PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u)
dkato 0:c5448e500c90 47 #define VIDEO_BUFFER_HEIGHT (PIXEL_VW)
dkato 0:c5448e500c90 48
dkato 0:c5448e500c90 49 DigitalIn button(USER_BUTTON0);
dkato 0:c5448e500c90 50
dkato 0:c5448e500c90 51 static uint8_t FrameBuffer_Video[VIDEO_BUFFER_STRIDE * VIDEO_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(16))); //16 bytes aligned!;
dkato 0:c5448e500c90 52 static volatile int32_t vsync_count = 0;
dkato 0:c5448e500c90 53 static volatile int32_t vfield_count = 1;
dkato 1:ebff3aeb40a0 54 static uint8_t JpegBuffer[2][1024 * 50]__attribute((section("NC_BSS"),aligned(8))); //8 bytes aligned!;
dkato 1:ebff3aeb40a0 55 static size_t jcu_encode_size[2];
dkato 0:c5448e500c90 56 static int image_change = 0;
dkato 1:ebff3aeb40a0 57 JPEG_Converter Jcu;
dkato 1:ebff3aeb40a0 58 static int jcu_buf_index_write = 0;
dkato 1:ebff3aeb40a0 59 static int jcu_buf_index_write_done = 0;
dkato 1:ebff3aeb40a0 60 static int jcu_buf_index_read = 0;
dkato 1:ebff3aeb40a0 61 static int jcu_encoding = 0;
dkato 1:ebff3aeb40a0 62
dkato 1:ebff3aeb40a0 63 static void JcuEncodeCallBackFunc(JPEG_Converter::jpeg_conv_error_t err_code) {
dkato 1:ebff3aeb40a0 64 jcu_buf_index_write_done = jcu_buf_index_write;
dkato 1:ebff3aeb40a0 65 image_change = 1;
dkato 1:ebff3aeb40a0 66 jcu_encoding = 0;
dkato 1:ebff3aeb40a0 67 }
dkato 0:c5448e500c90 68
dkato 0:c5448e500c90 69 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
dkato 0:c5448e500c90 70 //Interrupt callback function
dkato 0:c5448e500c90 71 if (vfield_count != 0) {
dkato 0:c5448e500c90 72 vfield_count = 0;
dkato 0:c5448e500c90 73 } else {
dkato 0:c5448e500c90 74 vfield_count = 1;
dkato 1:ebff3aeb40a0 75
dkato 1:ebff3aeb40a0 76 JPEG_Converter::bitmap_buff_info_t bitmap_buff_info;
dkato 1:ebff3aeb40a0 77 JPEG_Converter::encode_options_t encode_options;
dkato 1:ebff3aeb40a0 78
dkato 1:ebff3aeb40a0 79 bitmap_buff_info.width = PIXEL_HW;
dkato 1:ebff3aeb40a0 80 bitmap_buff_info.height = PIXEL_VW;
dkato 1:ebff3aeb40a0 81 bitmap_buff_info.format = JPEG_Converter::WR_RD_YCbCr422;
dkato 1:ebff3aeb40a0 82 bitmap_buff_info.buffer_address = (void *)FrameBuffer_Video;
dkato 1:ebff3aeb40a0 83
dkato 1:ebff3aeb40a0 84 encode_options.encode_buff_size = sizeof(JpegBuffer[0]);
dkato 1:ebff3aeb40a0 85 encode_options.p_EncodeCallBackFunc = &JcuEncodeCallBackFunc;
dkato 1:ebff3aeb40a0 86
dkato 1:ebff3aeb40a0 87 jcu_encoding = 1;
dkato 1:ebff3aeb40a0 88 if (jcu_buf_index_read == jcu_buf_index_write) {
dkato 1:ebff3aeb40a0 89 if (jcu_buf_index_write != 0) {
dkato 1:ebff3aeb40a0 90 jcu_buf_index_write = 0;
dkato 1:ebff3aeb40a0 91 } else {
dkato 1:ebff3aeb40a0 92 jcu_buf_index_write = 1;
dkato 1:ebff3aeb40a0 93 }
dkato 1:ebff3aeb40a0 94 }
dkato 1:ebff3aeb40a0 95 jcu_encode_size[jcu_buf_index_write] = 0;
dkato 1:ebff3aeb40a0 96 if (Jcu.encode(&bitmap_buff_info, JpegBuffer[jcu_buf_index_write], &jcu_encode_size[jcu_buf_index_write], &encode_options) != JPEG_Converter::JPEG_CONV_OK) {
dkato 1:ebff3aeb40a0 97 jcu_encode_size[jcu_buf_index_write] = 0;
dkato 1:ebff3aeb40a0 98 jcu_encoding = 0;
dkato 1:ebff3aeb40a0 99 }
dkato 0:c5448e500c90 100 }
dkato 0:c5448e500c90 101 }
dkato 0:c5448e500c90 102
dkato 0:c5448e500c90 103 static void IntCallbackFunc_Vsync(DisplayBase::int_type_t int_type) {
dkato 0:c5448e500c90 104 //Interrupt callback function for Vsync interruption
dkato 0:c5448e500c90 105 if (vsync_count > 0) {
dkato 0:c5448e500c90 106 vsync_count--;
dkato 0:c5448e500c90 107 }
dkato 0:c5448e500c90 108 }
dkato 0:c5448e500c90 109
dkato 0:c5448e500c90 110 static void WaitVsync(const int32_t wait_count) {
dkato 0:c5448e500c90 111 //Wait for the specified number of times Vsync occurs
dkato 0:c5448e500c90 112 vsync_count = wait_count;
dkato 0:c5448e500c90 113 while (vsync_count > 0) {
dkato 0:c5448e500c90 114 /* Do nothing */
dkato 0:c5448e500c90 115 }
dkato 0:c5448e500c90 116 }
dkato 0:c5448e500c90 117
dkato 0:c5448e500c90 118 static void camera_start(void) {
dkato 0:c5448e500c90 119 DisplayBase::graphics_error_t error;
dkato 0:c5448e500c90 120
dkato 0:c5448e500c90 121 #if VIDEO_INPUT_METHOD == VIDEO_CMOS_CAMERA
dkato 0:c5448e500c90 122 DisplayBase::video_ext_in_config_t ext_in_config;
dkato 0:c5448e500c90 123 PinName cmos_camera_pin[11] = {
dkato 0:c5448e500c90 124 /* data pin */
dkato 0:c5448e500c90 125 P2_7, P2_6, P2_5, P2_4, P2_3, P2_2, P2_1, P2_0,
dkato 0:c5448e500c90 126 /* control pin */
dkato 0:c5448e500c90 127 P10_0, /* DV0_CLK */
dkato 0:c5448e500c90 128 P1_0, /* DV0_Vsync */
dkato 0:c5448e500c90 129 P1_1 /* DV0_Hsync */
dkato 0:c5448e500c90 130 };
dkato 0:c5448e500c90 131 #endif
dkato 0:c5448e500c90 132
dkato 0:c5448e500c90 133 /* Create DisplayBase object */
dkato 0:c5448e500c90 134 DisplayBase Display;
dkato 0:c5448e500c90 135
dkato 0:c5448e500c90 136 /* Graphics initialization process */
dkato 0:c5448e500c90 137 error = Display.Graphics_init(NULL);
dkato 0:c5448e500c90 138 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:c5448e500c90 139 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 140 while (1);
dkato 0:c5448e500c90 141 }
dkato 0:c5448e500c90 142
dkato 0:c5448e500c90 143 #if VIDEO_INPUT_METHOD == VIDEO_CVBS
dkato 0:c5448e500c90 144 error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_VDEC, NULL);
dkato 0:c5448e500c90 145 if( error != DisplayBase::GRAPHICS_OK ) {
dkato 0:c5448e500c90 146 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 147 while(1);
dkato 0:c5448e500c90 148 }
dkato 0:c5448e500c90 149
dkato 0:c5448e500c90 150 #elif VIDEO_INPUT_METHOD == VIDEO_CMOS_CAMERA
dkato 0:c5448e500c90 151 /* MT9V111 camera input config */
dkato 0:c5448e500c90 152 ext_in_config.inp_format = DisplayBase::VIDEO_EXTIN_FORMAT_BT601; /* BT601 8bit YCbCr format */
dkato 0:c5448e500c90 153 ext_in_config.inp_pxd_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing data */
dkato 0:c5448e500c90 154 ext_in_config.inp_vs_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing Vsync signals */
dkato 0:c5448e500c90 155 ext_in_config.inp_hs_edge = DisplayBase::EDGE_RISING; /* Clock edge select for capturing Hsync signals */
dkato 0:c5448e500c90 156 ext_in_config.inp_endian_on = DisplayBase::OFF; /* External input bit endian change on/off */
dkato 0:c5448e500c90 157 ext_in_config.inp_swap_on = DisplayBase::OFF; /* External input B/R signal swap on/off */
dkato 0:c5448e500c90 158 ext_in_config.inp_vs_inv = DisplayBase::SIG_POL_NOT_INVERTED; /* External input DV_VSYNC inversion control */
dkato 0:c5448e500c90 159 ext_in_config.inp_hs_inv = DisplayBase::SIG_POL_INVERTED; /* External input DV_HSYNC inversion control */
dkato 0:c5448e500c90 160 ext_in_config.inp_f525_625 = DisplayBase::EXTIN_LINE_525; /* Number of lines for BT.656 external input */
dkato 0:c5448e500c90 161 ext_in_config.inp_h_pos = DisplayBase::EXTIN_H_POS_CRYCBY; /* Y/Cb/Y/Cr data string start timing to Hsync reference */
dkato 0:c5448e500c90 162 ext_in_config.cap_vs_pos = 6; /* Capture start position from Vsync */
dkato 0:c5448e500c90 163 ext_in_config.cap_hs_pos = 150; /* Capture start position form Hsync */
dkato 0:c5448e500c90 164 ext_in_config.cap_width = 640; /* Capture width */
dkato 0:c5448e500c90 165 ext_in_config.cap_height = 468u; /* Capture height Max 468[line]
dkato 0:c5448e500c90 166 Due to CMOS(MT9V111) output signal timing and VDC5 specification */
dkato 0:c5448e500c90 167 error = Display.Graphics_Video_init( DisplayBase::INPUT_SEL_EXT, &ext_in_config);
dkato 0:c5448e500c90 168 if( error != DisplayBase::GRAPHICS_OK ) {
dkato 0:c5448e500c90 169 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 170 while(1);
dkato 0:c5448e500c90 171 }
dkato 0:c5448e500c90 172
dkato 0:c5448e500c90 173 /* MT9V111 camera input port setting */
dkato 0:c5448e500c90 174 error = Display.Graphics_Dvinput_Port_Init(cmos_camera_pin, 11);
dkato 0:c5448e500c90 175 if( error != DisplayBase::GRAPHICS_OK ) {
dkato 0:c5448e500c90 176 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 177 while (1);
dkato 0:c5448e500c90 178 }
dkato 0:c5448e500c90 179 #endif
dkato 0:c5448e500c90 180
dkato 0:c5448e500c90 181 /* Interrupt callback function setting (Vsync signal input to scaler 0) */
dkato 0:c5448e500c90 182 error = Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VI_VSYNC, 0, IntCallbackFunc_Vsync);
dkato 0:c5448e500c90 183 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:c5448e500c90 184 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 185 while (1);
dkato 0:c5448e500c90 186 }
dkato 0:c5448e500c90 187 /* Video capture setting (progressive form fixed) */
dkato 0:c5448e500c90 188 error = Display.Video_Write_Setting(
dkato 0:c5448e500c90 189 VIDEO_INPUT_CH,
dkato 0:c5448e500c90 190 #if VIDEO_PAL == 0
dkato 0:c5448e500c90 191 DisplayBase::COL_SYS_NTSC_358,
dkato 0:c5448e500c90 192 #else
dkato 0:c5448e500c90 193 DisplayBase::COL_SYS_PAL_443,
dkato 0:c5448e500c90 194 #endif
dkato 0:c5448e500c90 195 FrameBuffer_Video,
dkato 0:c5448e500c90 196 VIDEO_BUFFER_STRIDE,
dkato 0:c5448e500c90 197 #if VIDEO_INPUT_FORMAT == VIDEO_YCBCR422
dkato 0:c5448e500c90 198 DisplayBase::VIDEO_FORMAT_YCBCR422,
dkato 0:c5448e500c90 199 DisplayBase::WR_RD_WRSWA_NON,
dkato 0:c5448e500c90 200 #elif VIDEO_INPUT_FORMAT == VIDEO_RGB565
dkato 0:c5448e500c90 201 DisplayBase::VIDEO_FORMAT_RGB565,
dkato 0:c5448e500c90 202 DisplayBase::WR_RD_WRSWA_32_16BIT,
dkato 0:c5448e500c90 203 #else
dkato 0:c5448e500c90 204 DisplayBase::VIDEO_FORMAT_RGB888,
dkato 0:c5448e500c90 205 DisplayBase::WR_RD_WRSWA_32BIT,
dkato 0:c5448e500c90 206 #endif
dkato 0:c5448e500c90 207 PIXEL_VW,
dkato 0:c5448e500c90 208 PIXEL_HW
dkato 0:c5448e500c90 209 );
dkato 0:c5448e500c90 210 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:c5448e500c90 211 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 212 while (1);
dkato 0:c5448e500c90 213 }
dkato 0:c5448e500c90 214
dkato 0:c5448e500c90 215 /* Interrupt callback function setting (Field end signal for recording function in scaler 0) */
dkato 0:c5448e500c90 216 error = Display.Graphics_Irq_Handler_Set(VIDEO_INT_TYPE, 0, IntCallbackFunc_Vfield);
dkato 0:c5448e500c90 217 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:c5448e500c90 218 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 219 while (1);
dkato 0:c5448e500c90 220 }
dkato 0:c5448e500c90 221
dkato 0:c5448e500c90 222 /* Video write process start */
dkato 0:c5448e500c90 223 error = Display.Video_Start (VIDEO_INPUT_CH);
dkato 0:c5448e500c90 224 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:c5448e500c90 225 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 226 while (1);
dkato 0:c5448e500c90 227 }
dkato 0:c5448e500c90 228
dkato 0:c5448e500c90 229 /* Video write process stop */
dkato 0:c5448e500c90 230 error = Display.Video_Stop (VIDEO_INPUT_CH);
dkato 0:c5448e500c90 231 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:c5448e500c90 232 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 233 while (1);
dkato 0:c5448e500c90 234 }
dkato 0:c5448e500c90 235
dkato 0:c5448e500c90 236 /* Video write process start */
dkato 0:c5448e500c90 237 error = Display.Video_Start (VIDEO_INPUT_CH);
dkato 0:c5448e500c90 238 if (error != DisplayBase::GRAPHICS_OK) {
dkato 0:c5448e500c90 239 printf("Line %d, error %d\n", __LINE__, error);
dkato 0:c5448e500c90 240 while (1);
dkato 0:c5448e500c90 241 }
dkato 0:c5448e500c90 242
dkato 0:c5448e500c90 243 /* Wait vsync to update resister */
dkato 0:c5448e500c90 244 WaitVsync(1);
dkato 0:c5448e500c90 245 }
dkato 0:c5448e500c90 246
dkato 0:c5448e500c90 247 static int snapshot_req(const char ** pp_data) {
dkato 1:ebff3aeb40a0 248 int encode_size;
dkato 0:c5448e500c90 249
dkato 1:ebff3aeb40a0 250 while ((jcu_encoding == 1) || (image_change == 0)) {
dkato 0:c5448e500c90 251 Thread::wait(1);
dkato 0:c5448e500c90 252 }
dkato 1:ebff3aeb40a0 253 jcu_buf_index_read = jcu_buf_index_write_done;
dkato 0:c5448e500c90 254 image_change = 0;
dkato 0:c5448e500c90 255
dkato 1:ebff3aeb40a0 256 *pp_data = (const char *)JpegBuffer[jcu_buf_index_read];
dkato 1:ebff3aeb40a0 257 encode_size = (int)jcu_encode_size[jcu_buf_index_read];
dkato 0:c5448e500c90 258
dkato 1:ebff3aeb40a0 259 return encode_size;
dkato 0:c5448e500c90 260 }
dkato 0:c5448e500c90 261
dkato 0:c5448e500c90 262 static void TerminalWrite(Arguments* arg, Reply* r) {
dkato 0:c5448e500c90 263 printf("%s\n",arg->argv[0]);
dkato 0:c5448e500c90 264 }
dkato 0:c5448e500c90 265
dkato 0:c5448e500c90 266 static void mount_romramfs(void) {
dkato 0:c5448e500c90 267 FILE * fp;
dkato 0:c5448e500c90 268
dkato 0:c5448e500c90 269 romramfs.format();
dkato 0:c5448e500c90 270
dkato 0:c5448e500c90 271 //camera.js
dkato 0:c5448e500c90 272 fp = fopen("/romram/camera.js", "w");
dkato 0:c5448e500c90 273 fwrite(camaera_js_tbl, sizeof(char), sizeof(camaera_js_tbl), fp);
dkato 0:c5448e500c90 274 fclose(fp);
dkato 0:c5448e500c90 275
dkato 0:c5448e500c90 276 //camera.htm
dkato 0:c5448e500c90 277 fp = fopen("/romram/camera.htm", "w");
dkato 0:c5448e500c90 278 fwrite(camera_htm_tbl, sizeof(char), sizeof(camera_htm_tbl), fp);
dkato 0:c5448e500c90 279 fclose(fp);
dkato 0:c5448e500c90 280
dkato 0:c5448e500c90 281 //mbedrpc.js
dkato 0:c5448e500c90 282 fp = fopen("/romram/mbedrpc.js", "w");
dkato 0:c5448e500c90 283 fwrite(mbedrpc_js_tbl, sizeof(char), sizeof(mbedrpc_js_tbl), fp);
dkato 0:c5448e500c90 284 fclose(fp);
dkato 0:c5448e500c90 285
dkato 0:c5448e500c90 286 //led.htm
dkato 0:c5448e500c90 287 fp = fopen("/romram/led.htm", "w");
dkato 0:c5448e500c90 288 fwrite(led_htm_tbl, sizeof(char), sizeof(led_htm_tbl), fp);
dkato 0:c5448e500c90 289 fclose(fp);
dkato 0:c5448e500c90 290 }
dkato 0:c5448e500c90 291
dkato 0:c5448e500c90 292 int main(void) {
dkato 0:c5448e500c90 293 printf("********* PROGRAM START ***********\r\n");
dkato 0:c5448e500c90 294
dkato 0:c5448e500c90 295 mount_romramfs(); //RomRamFileSystem Mount
dkato 0:c5448e500c90 296 camera_start(); //Camera Start
dkato 0:c5448e500c90 297
dkato 0:c5448e500c90 298 RPC::add_rpc_class<RpcDigitalOut>();
dkato 0:c5448e500c90 299 RPC::construct<RpcDigitalOut, PinName, const char*>(LED1, "led1");
dkato 0:c5448e500c90 300 RPC::construct<RpcDigitalOut, PinName, const char*>(LED2, "led2");
dkato 0:c5448e500c90 301 RPC::construct<RpcDigitalOut, PinName, const char*>(LED3, "led3");
dkato 0:c5448e500c90 302 RPCFunction rpcFunc(TerminalWrite, "TerminalWrite");
dkato 0:c5448e500c90 303
dkato 0:c5448e500c90 304 printf("EthernetInterface Setting up...\r\n");
dkato 2:82a6d79d05f0 305 if (eth.init() != 0) { //for DHCP Server
dkato 2:82a6d79d05f0 306 // if (eth.init("192.168.0.2","255.255.255.0","192.168.0.3") != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway)
dkato 0:c5448e500c90 307 printf("EthernetInterface Initialize Error \r\n");
dkato 0:c5448e500c90 308 return -1;
dkato 0:c5448e500c90 309 }
dkato 0:c5448e500c90 310 if (eth.connect() != 0) {
dkato 0:c5448e500c90 311 printf("EthernetInterface Connect Error \r\n");
dkato 0:c5448e500c90 312 return -1;
dkato 0:c5448e500c90 313 }
dkato 0:c5448e500c90 314 printf("IP Address is %s\r\n", eth.getIPAddress());
dkato 0:c5448e500c90 315 printf("NetMask is %s\r\n", eth.getNetworkMask());
dkato 0:c5448e500c90 316 printf("Gateway Address is %s\r\n", eth.getGateway());
dkato 0:c5448e500c90 317 printf("Ethernet Setup OK\r\n");
dkato 0:c5448e500c90 318
dkato 0:c5448e500c90 319 SnapshotHandler::attach_req(&snapshot_req);
dkato 0:c5448e500c90 320 HTTPServerAddHandler<SnapshotHandler>("/camera"); //Camera
dkato 0:c5448e500c90 321 FSHandler::mount("/romram", "/");
dkato 0:c5448e500c90 322 HTTPServerAddHandler<FSHandler>("/");
dkato 0:c5448e500c90 323 HTTPServerAddHandler<RPCHandler>("/rpc");
dkato 0:c5448e500c90 324 HTTPServerStart(80);
dkato 0:c5448e500c90 325 }