Web Camera for mbed-os. This sample works on GR-LYCHEE besides GR-PEACH. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Dependencies:   HttpServer_snapshot_mbed-os

License

When you use this program, we judge you have agreed to the following contents.
本プログラムを使用する際は、以下の内容に合意した事になります。

https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Information

Japanese version is available in lower part of this page.
このページの後半に日本語版が用意されています.

Video Links on how to setup and run WebCamera Application:

Your video will be live at:

Overview

This is a sample program that works on GR-PEACH or GR-LYCHEE.
This is a web camera sample program. When accessing from the Web browser, the following will be displayed.

  • Camera input picture
  • Control screen of devices connected to the I2C bus
  • LED control screen

Requirements

For GR-PEACH (via Wi-Fi):

  • GR-PEACH
  • GR-PEACH Wireless CAMERA Shield : OV7725

For GR-PEACH (via Ether):

  • GR-PEACH
  • One of the following
    • GR-PEACH Wireless CAMERA Shield : OV7725
    • NTSC analog camera
    • MT9V111 and GR-PEACH AUDIO CAMERA Shield
    • OV5642 and GR-PEACH AUDIO CAMERA Shield

For GR-LYCHEE (via Wi-Fi):

  • GR-LYCHEE

How to use

Turn on the power to the GR-Board and start the terminal software.
The default value of the bow rate with mbed is 9600, and in this sample we use the baud rate 9600.

When you press the reset button of GR-Board, the scan result of Wifi will be output on Terminal. Please refer to the following link for usage of Terminal.

********* PROGRAM START ***********
Network Setting up...
Scan:
No.0 Network: SSID_1 secured:WPA/WPA2 BSSID: xx:xx:xx:xx:xx:xx RSSI: -52 Ch: 1
No.1 Network: SSID_2 secured: Unknown BSSID: xx:xx:xx:xx:xx:xx RSSI: -67 Ch: 2
2 networks available.

Please enter the number of the network you want to connect.
Enter key:[0]-[1], (If inputting the other key, it's scanned again.)

Enter the number of the network you want to connect from the keyboard. To select SSID_1, press "0" on the keyboard.

[SSID_1] is selected.
please enter the PSK.

Finally, enter the password to connect to the network.

If the connection is successful, the IP address is output on Terminal.

connecting...
MAC Address is xx:xx:xx:xx:xx:xx
IP Address is 192.168.0.2
NetMask is 255.255.255.240
Gateway Address is 192.168.0.1
Network Setup OK

When you open IP Address ("192.168.0.2" in the above example) by a Web browser, top screen is indicated. The configuration of the top screen is a menu screen on the left side, a description screen of the sample program on the right side. If you click on each menu on the left side of the screen, the screen along the menu is indicated on the right screen.

Page Top

/media/uploads/1050186/web_top2.jpg

Web Camera

/media/uploads/1050186/camera3.jpg
When you click the "Web camera" in the menu screen, the pictures of a camera is indicated. It can be changed at a slider bar in "Wait time" at the timing of a renewal of a camera picture. (Defaults are 500ms.)

Setting by I2C

/media/uploads/1050186/setting_i2c3.jpg
When you click the "Setting by I2C" of the menu screen, the control screen of the device connected to the I2C bus is indicated. By sending a command of a format listed below("Format of the device set by I2C") in Direct input or File reference, data transmission and reception is possible with respect to devices connected to I2C_SDA and I2C_SCL terminals of I2C. The communication log of transmission and reception by "Format of the device set by I2C" is displayed in the log window. When you press the "Clear" button, the log is cleared. When you press the "Save" button, the log is saved.

Format of the device set by I2C

Method:I2C addr,data length,data1,data2,data3,...

The details of each parameter is shown below.
For specific settings, check on the specifications of the connected device, you must create a command along the format.

MethodPlease specify one of the following:
"Wr" ・・・ Write functions in I2C
"Rd" ・・・ Read functions in I2C
"WrNoP" ・・・ Write functions in I2C(No STOP condition)
"RdNoP" ・・・ Read functions in I2C(No STOP condition)
I2C addrSet the I2C address of device in hexadecimal.
Ex: If the address is 0x90, set the "90"
data lengthIf Method is "Wr" or "WrNoP", set write size(the size of the data portion) in hexadecimal.
Ex: If the write size is 2 byte(data1, data2), set the "02".
If Method is "Rd" or "RdNoP", set read size in hexadecimal.
Ex: If the read size is 10 byte, set the "0A".
dataIf Method is "Wr" or "WrNoP", set write data in 1 byte unit in hexadecimal.
Ex: If the write data is 0x01 0x02, set "01" in the data1 and "02" in the data2.
If Method is "Rd" or "RdNoP", this parameter is omitted.

An example of the format is shown below.

Wr:90,03,25,45,14

To the device of the I2C address 0x90, the data write of 3Byte(0x25 0x45 0x14)

Rd:90,02

To the device of the I2C address 0x90, the data read of 2Byte

LED On/Off

/media/uploads/1050186/led2.jpg
When you click the "LED On/Off" of the menu screen, the LED control screen is indicated. Each switch switches of GR-Boards to ON or OFF. Each switch indicates the current LED state. When the LED is On, the color of switch will change the LED color.

Switch to web page in SD card

Web pages displayed on the Web browser are located in the built-in ROM. file_table_peach.h is saved as table information for GR-PEACH and file_table_lychee.h is saved as table information for GR-LYCHEE. The contents of the saved file are as follows.

When connecting the SD card, SDBlockDevice will be displayed on the terminal and the web page displayed in the web browser will switch from the built-in ROM to the SD card. The top page is index.htm.

Change network connection

You can change the network connection by changing the following macro in main.cpp.

/**** User Selection *********/
#define NETWORK_TYPE           (2)                 /* Select  0(Ethernet), 1(BP3595), 2(ESP32 STA) ,3(ESP32 AP) */
#if (NETWORK_TYPE >= 1)
  #define SCAN_NETWORK         (1)                 /* Select  0(Use WLAN_SSID, WLAN_PSK, WLAN_SECURITY) or 1(To select a network using the terminal.) */
  #define WLAN_SSID            ("SSIDofYourAP")    /* SSID */
  #define WLAN_PSK             ("PSKofYourAP")     /* PSK(Pre-Shared Key) */
  #define WLAN_SECURITY        NSAPI_SECURITY_WPA_WPA2 /* NSAPI_SECURITY_NONE, NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2 or NSAPI_SECURITY_WPA_WPA2 */
#endif

Depending on the value set for NETWORK_TYPE, the connection method changes as follows.

NumberConnectionDescription
0EthernetGR-PEACH only
1reservedIt can not be selected.
2ESP32 STAUse ESP32 in STA mode.
3ESP32 APUse ESP32 in AP mode.

When using GR-LYCHEE, NETWORK_TYPE 2 and 3 can be selected.
GR-PEACH Wireless CAMERA Shield is required separately when using ESP32 with GR-PEACH.

When using Ethernet, the user must provide the MAC address.
To specify MAC address, add fllowing function to main.cpp.

Specify MAC address

// set mac address
void mbed_mac_address(char *mac) {
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
}

Camera selection

To select the Camera, add camera-type to mbed_app.json.
See here for details.

mbed_app.json

{
    "config": {
        "camera":{
            "help": "0:disable 1:enable",
            "value": "1"
        },
        "camera-type":{
            "help": "Please see EasyAttach_CameraAndLCD/README.md",
            "value": null
        },
        "lcd":{
            "help": "0:disable 1:enable",
            "value": "0"
        },
        "lcd-type":{
            "help": "Please see EasyAttach_CameraAndLCD/README.md",
            "value": null
        }
    },
    "target_overrides": {
        "RZ_A1H": {
            "camera-type" : "CAMERA_WIRELESS_CAMERA"
        }
    }
}

Appendix


概要

GR-PEACH、および、GR-LYCHEEで動作するサンプルプログラムです。
Webカメラのサンプルです。Webブラウザからアクセスすると以下が表示されます。

  • Camera入力画像
  • I2Cバスに繋がっているデバイスの制御画面
  • LED操作画面

構成

GR-PEACH (Wi-Fi経由)の場合:

  • GR-PEACH
  • GR-PEACH Wireless CAMERA Shield : OV7725

GR-PEACH (Ether経由)の場合:

  • GR-PEACH
  • 以下のいずれか
    • GR-PEACH Wireless CAMERA Shield : OV7725
    • NTSCアナログカメラ
    • MT9V111 and GR-PEACH AUDIO CAMERA Shield
    • OV5642 and GR-PEACH AUDIO CAMERA Shield

GR-LYCHEE(Wi-Fi経由)の場合:

  • GR-LYCHEE

使い方

GR-Boardに電源を入れ、Terminalソフトを立ち上げます。
Mbedでのボーレートのデフォルト値は9600で、このサンプルではボーレート9600を使います。

GR-Boardのリセットボタンを押すと、Terminal上にWifiのスキャン結果が出力されます。

********* PROGRAM START ***********
Network Setting up...
Scan:
No.0 Network: SSID_1 secured:WPA/WPA2 BSSID: xx:xx:xx:xx:xx:xx RSSI: -52 Ch: 1
No.1 Network: SSID_2 secured: Unknown BSSID: xx:xx:xx:xx:xx:xx RSSI: -67 Ch: 2
2 networks available.

Please enter the number of the network you want to connect.
Enter key:[0]-[1], (If inputting the other key, it's scanned again.)

接続したいネットワークの番号をキーボードから入力します。0番のSSID_1を選択する場合はキーボードの "0" を押します。

[SSID_1] is selected.
please enter the PSK.

最後にネットワークに接続するためのパスワードを入力します。

接続に成功すると、Terminal上にIPアドレスが出力されます。

connecting...
MAC Address is xx:xx:xx:xx:xx:xx
IP Address is 192.168.0.2
NetMask is 255.255.255.240
Gateway Address is 192.168.0.1
Network Setup OK

PCのWebブラウザで Terminalに表示された IP Address (上記例では 192.168.0.2)を開くと、トップ画面が表示されます。トップ画面は、左側にメニュー画面、右側にサンプルプログラムの説明画面という構成になっており、左画面の各メニューをクリックすると、メニューに沿った画面が右画面に表示されます。

Page Top 画面

/media/uploads/1050186/web_top2.jpg

Web Camera 画面

/media/uploads/1050186/camera3.jpg
メニュー画面の”Web Camera”をクリックすると、Camera画像が表示されます。
"Wait time"のスライダーバーでCamera画像の更新タイミングが変更できます。(初期値は500msです)

Setting by I2C 画面

/media/uploads/1050186/setting_i2c3.jpg

メニュー画面の"Setting by I2C"をクリックすると、I2Cバスに繋がっているデバイスの制御画面が表示されます。直接入力(Direct input)欄又はファイル参照(File reference)欄にて、下記("I2Cによるデバイス設定のフォーマット")に記載されているフォーマットのコマンドを送信する事で、I2CのI2C_SDA,I2C_SCL端子に繋がっているデバイスに対して、データの送受信が可能です。"I2Cによるデバイス設定のフォーマット"による送受信の通信ログは、ログウィンドウに表示されます。"Clear"ボタンを押すとログのクリア、"Save"ボタンを押すとログの保存ができます。

I2Cによるデバイス設定のフォーマット

Method:I2C addr,data length,data1,data2,data3,...

各パラメータの詳細を以下に示します。
具体的な設定値については、接続先のデバイスの仕様をご確認のうえ、フォーマットに沿ってコマンドを作成して下さい。

Method以下のいづれかを指定して下さい
"Wr" ・・・ I2Cでの書き込み
"Rd" ・・・ I2Cでの読み出し
"WrNoP" ・・・ I2Cでの書き込み(STOPコンディション省略)
"RdNoP" ・・・ I2Cでの読み出し(STOPコンディション省略)
I2C addr接続先デバイスのI2Cアドレスを16進数で設定して下さい。
(例) アドレスが0x90の場合、"90"を設定
data lengthMethodが"Wr"又は"WrNoP"の場合、書き込むサイズ(data部分のサイズ)を16進数で設定して下さい。
(例) 書き込むサイズが2Byte(data1,data2)の場合、"02"を設定
Methodが"Rd"又は"RdNoP"の場合は読み取るサイズを16進数で設定して下さい。
(例) 読み取りサイズが10Byteの場合、"0A"を設定
dataMethodが"Wr"又は"WrNoP"の場合、書き込むデータを16進数で1Byte単位で設定して下さい。
(例) 書き込みデータが0x01,0x02の場合、data1に"01"、data2に"02"を設定
"Rd"又は"RdNoP"の場合は省略して下さい。

フォーマットの例を以下に示します。

Wr:90,03,25,45,14

I2Cアドレス0x90のデバイスに対して0x25 0x45 0x14の計3Byteのデータ書き込み

Rd:90,02

I2Cアドレス0x90のデバイスに対して2Byteのデータ読み出し

LED On/Off 画面

/media/uploads/1050186/led2.jpg
メニュー画面の"LED On/Off"をクリックすると、LED操作画面が表示されます。各スイッチはGR-BoardのLED ON/OFFを切り替えます。スイッチはそれぞれGR-BoardのLEDの現在の状態を表しており、ONにすると対応するLEDの色になります。

SDカード内のWebページに切り替える

Webブラウザで表示されるWebページは内蔵ROMに配置されています。file_table_peach.h はGR-PEACH用、 file_table_lychee.h はGR-LYCHEE用のWebページがテーブル情報として保存されています。保存されているファイルの内容は下記の通りです。

SDカードを接続するとTerminal上に SDBlockDevice と表示され、Webブラウザで表示されるWebページが内蔵ROMからSDカードに切り替わります。トップページは index.htm となります。

ネットワークの接続方法を変更する

main.cppの下記マクロを変更することでネットワークの接続方法を変更できます。

/**** User Selection *********/
#define NETWORK_TYPE           (2)                 /* Select  0(Ethernet), 1(BP3595), 2(ESP32 STA) ,3(ESP32 AP) */
#if (NETWORK_TYPE >= 1)
  #define SCAN_NETWORK         (1)                 /* Select  0(Use WLAN_SSID, WLAN_PSK, WLAN_SECURITY) or 1(To select a network using the terminal.) */
  #define WLAN_SSID            ("SSIDofYourAP")    /* SSID */
  #define WLAN_PSK             ("PSKofYourAP")     /* PSK(Pre-Shared Key) */
  #define WLAN_SECURITY        NSAPI_SECURITY_WPA_WPA2 /* NSAPI_SECURITY_NONE, NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2 or NSAPI_SECURITY_WPA_WPA2 */
#endif

NETWORK_TYPE に設定する値により、以下の接続方法に切り替わります。

番号接続方法説明
0EthernetGR-PEACHのみ。
1reserved選択できません。
2ESP32 STAESP32をSTAモードで使用します。
3ESP32 APESP32をAPモードで使用します。

GR-LYCHEEを使用する場合はNETWORK_TYPE 2と3が選択できます。
GR-PEACHでNETWORK_TYPE 2と3を使用する場合は別途GR-PEACH Wireless/Cameraシールドが必要です。

NETWORK_TYPE 1のEthernetを使う場合はMACアドレスをユーザが用意する必要があります。
"main.cpp"の最後にの下記のように関数を追加し、用意したMACアドレスを設定してください。

Specify MAC address

// set mac address
void mbed_mac_address(char *mac) {
    mac[0] = 0x00;
    mac[1] = 0x02;
    mac[2] = 0xF7;
    mac[3] = 0xF0;
    mac[4] = 0x00;
    mac[5] = 0x00;
}

カメラの設定

カメラの指定を行う場合はmbed_app.jsonにcamera-typeを変更して追加してください。
詳細はこちらを参照ください。

mbed_app.json

{
    "config": {
        "camera":{
            "help": "0:disable 1:enable",
            "value": "1"
        },
        "camera-type":{
            "help": "Please see EasyAttach_CameraAndLCD/README.md",
            "value": null
        },
        "lcd":{
            "help": "0:disable 1:enable",
            "value": "0"
        },
        "lcd-type":{
            "help": "Please see EasyAttach_CameraAndLCD/README.md",
            "value": null
        }
    },
    "target_overrides": {
        "RZ_A1H": {
            "camera-type" : "CAMERA_WIRELESS_CAMERA"
        }
    }
}

付録

Committer:
dkato
Date:
Thu Oct 03 07:39:23 2019 +0000
Revision:
24:63e5f399af4a
Parent:
23:e7fd26563f8f
Child:
25:39a4685774bc
Update libraries

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:c5448e500c90 1 #include "mbed.h"
1050186 23:e7fd26563f8f 2 #include "EasyAttach_CameraAndLCD.h"
1050186 23:e7fd26563f8f 3 #include "dcache-control.h"
dkato 0:c5448e500c90 4 #include "JPEG_Converter.h"
dkato 0:c5448e500c90 5 #include "HTTPServer.h"
dkato 0:c5448e500c90 6 #include "mbed_rpc.h"
dkato 21:c7de71ccb5ca 7 #include "FATFileSystem.h"
dkato 21:c7de71ccb5ca 8 #include "RomRamBlockDevice.h"
1050186 23:e7fd26563f8f 9 #include "SDBlockDevice_GRBoard.h"
1050186 23:e7fd26563f8f 10 #if defined(TARGET_RZ_A1H)
1050186 23:e7fd26563f8f 11 #include "file_table_peach.h" //Binary data of web pages
1050186 23:e7fd26563f8f 12 #elif defined(TARGET_GR_LYCHEE)
1050186 23:e7fd26563f8f 13 #include "file_table_lychee.h" //Binary data of web pages
1050186 23:e7fd26563f8f 14 #endif
1050186 5:34d84609dd60 15 #include "i2c_setting.h"
dkato 0:c5448e500c90 16
dkato 0:c5448e500c90 17 /**** User Selection *********/
dkato 11:ad8ff26679bb 18 /** Network setting **/
dkato 11:ad8ff26679bb 19 #define USE_DHCP (1) /* Select 0(static configuration) or 1(use DHCP) */
dkato 11:ad8ff26679bb 20 #if (USE_DHCP == 0)
dkato 11:ad8ff26679bb 21 #define IP_ADDRESS ("192.168.0.2") /* IP address */
dkato 11:ad8ff26679bb 22 #define SUBNET_MASK ("255.255.255.0") /* Subnet mask */
dkato 11:ad8ff26679bb 23 #define DEFAULT_GATEWAY ("192.168.0.3") /* Default gateway */
dkato 11:ad8ff26679bb 24 #endif
dkato 24:63e5f399af4a 25 #define NETWORK_TYPE (0) /* Select 0(Ethernet), 1(reserved), 2(ESP32 STA) ,3(ESP32 AP) */
dkato 24:63e5f399af4a 26 #if (NETWORK_TYPE >= 2)
dkato 17:2648bcf3f2cc 27 #define SCAN_NETWORK (1) /* Select 0(Use WLAN_SSID, WLAN_PSK, WLAN_SECURITY) or 1(To select a network using the terminal.) */
dkato 15:eac4c3711aab 28 #define WLAN_SSID ("SSIDofYourAP") /* SSID */
dkato 15:eac4c3711aab 29 #define WLAN_PSK ("PSKofYourAP") /* PSK(Pre-Shared Key) */
dkato 17:2648bcf3f2cc 30 #define WLAN_SECURITY NSAPI_SECURITY_WPA_WPA2 /* NSAPI_SECURITY_NONE, NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA, NSAPI_SECURITY_WPA2 or NSAPI_SECURITY_WPA_WPA2 */
dkato 15:eac4c3711aab 31 #endif
1050186 23:e7fd26563f8f 32 /** JPEG out setting **/
1050186 23:e7fd26563f8f 33 #define JPEG_ENCODE_QUALITY (75) /* JPEG encode quality (min:1, max:75 (Considering the size of JpegBuffer, about 75 is the upper limit.)) */
1050186 23:e7fd26563f8f 34 #define VFIELD_INT_SKIP_CNT (0) /* A guide for GR-LYCHEE. 0:60fps, 1:30fps, 2:20fps, 3:15fps, 4:12fps, 5:10fps */
dkato 0:c5448e500c90 35 /*****************************/
dkato 0:c5448e500c90 36
dkato 15:eac4c3711aab 37 #if (NETWORK_TYPE == 0)
dkato 15:eac4c3711aab 38 #include "EthernetInterface.h"
dkato 15:eac4c3711aab 39 EthernetInterface network;
dkato 15:eac4c3711aab 40 #elif (NETWORK_TYPE == 1)
1050186 23:e7fd26563f8f 41 #error "Not supported"
1050186 23:e7fd26563f8f 42 #elif (NETWORK_TYPE == 2)
1050186 23:e7fd26563f8f 43 #include "ESP32Interface.h"
dkato 24:63e5f399af4a 44 ESP32Interface network;
1050186 23:e7fd26563f8f 45 #elif (NETWORK_TYPE == 3)
1050186 23:e7fd26563f8f 46 #include "ESP32InterfaceAP.h"
dkato 24:63e5f399af4a 47 ESP32InterfaceAP network;
dkato 15:eac4c3711aab 48 #else
dkato 15:eac4c3711aab 49 #error NETWORK_TYPE error
dkato 15:eac4c3711aab 50 #endif /* NETWORK_TYPE */
1050186 23:e7fd26563f8f 51
1050186 23:e7fd26563f8f 52 /* Video input and LCD layer 0 output */
1050186 23:e7fd26563f8f 53 #define VIDEO_FORMAT (DisplayBase::VIDEO_FORMAT_YCBCR422)
1050186 23:e7fd26563f8f 54 #define GRAPHICS_FORMAT (DisplayBase::GRAPHICS_FORMAT_YCBCR422)
1050186 23:e7fd26563f8f 55 #define WR_RD_WRSWA (DisplayBase::WR_RD_WRSWA_32_16BIT)
1050186 23:e7fd26563f8f 56 #define DATA_SIZE_PER_PIC (2u)
1050186 23:e7fd26563f8f 57
1050186 23:e7fd26563f8f 58 /*! Frame buffer stride: Frame buffer stride should be set to a multiple of 32 or 128
1050186 23:e7fd26563f8f 59 in accordance with the frame buffer burst transfer mode. */
1050186 23:e7fd26563f8f 60 #define VIDEO_PIXEL_HW (320u) /* QVGA */
1050186 23:e7fd26563f8f 61 #define VIDEO_PIXEL_VW (240u) /* QVGA */
1050186 23:e7fd26563f8f 62
1050186 23:e7fd26563f8f 63 #define FRAME_BUFFER_STRIDE (((VIDEO_PIXEL_HW * DATA_SIZE_PER_PIC) + 31u) & ~31u)
1050186 23:e7fd26563f8f 64 #define FRAME_BUFFER_HEIGHT (VIDEO_PIXEL_VW)
1050186 23:e7fd26563f8f 65
1050186 23:e7fd26563f8f 66 DisplayBase Display;
dkato 0:c5448e500c90 67
dkato 14:212f66386982 68 #if defined(__ICCARM__)
1050186 23:e7fd26563f8f 69 #pragma data_alignment=32
1050186 23:e7fd26563f8f 70 static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]@ ".mirrorram";
dkato 14:212f66386982 71 #else
1050186 23:e7fd26563f8f 72 static uint8_t user_frame_buffer0[FRAME_BUFFER_STRIDE * FRAME_BUFFER_HEIGHT]__attribute((section("NC_BSS"),aligned(32)));
dkato 14:212f66386982 73 #endif
1050186 23:e7fd26563f8f 74
1050186 23:e7fd26563f8f 75 FATFileSystem fs("storage");
1050186 23:e7fd26563f8f 76 RomRamBlockDevice romram_bd(512000, 512);
1050186 23:e7fd26563f8f 77 SDBlockDevice_GRBoard sd;
1050186 23:e7fd26563f8f 78 Serial pc(USBTX, USBRX);
1050186 23:e7fd26563f8f 79 Thread sdConnectTask;
1050186 23:e7fd26563f8f 80
dkato 14:212f66386982 81 #if defined(__ICCARM__)
1050186 23:e7fd26563f8f 82 #pragma data_alignment=32
1050186 23:e7fd26563f8f 83 static uint8_t JpegBuffer[2][1024 * 64];
dkato 14:212f66386982 84 #else
1050186 23:e7fd26563f8f 85 static uint8_t JpegBuffer[2][1024 * 64]__attribute((aligned(32)));
dkato 14:212f66386982 86 #endif
dkato 1:ebff3aeb40a0 87 static size_t jcu_encode_size[2];
dkato 0:c5448e500c90 88 static int image_change = 0;
dkato 1:ebff3aeb40a0 89 JPEG_Converter Jcu;
dkato 1:ebff3aeb40a0 90 static int jcu_buf_index_write = 0;
dkato 1:ebff3aeb40a0 91 static int jcu_buf_index_write_done = 0;
dkato 1:ebff3aeb40a0 92 static int jcu_buf_index_read = 0;
dkato 1:ebff3aeb40a0 93 static int jcu_encoding = 0;
1050186 23:e7fd26563f8f 94 static int Vfield_Int_Cnt = 0;
dkato 7:c45ecff1b44d 95 static char i2c_setting_str_buf[I2C_SETTING_STR_BUF_SIZE];
dkato 1:ebff3aeb40a0 96
dkato 1:ebff3aeb40a0 97 static void JcuEncodeCallBackFunc(JPEG_Converter::jpeg_conv_error_t err_code) {
1050186 23:e7fd26563f8f 98 if (err_code == JPEG_Converter::JPEG_CONV_OK) {
1050186 23:e7fd26563f8f 99 jcu_buf_index_write_done = jcu_buf_index_write;
1050186 23:e7fd26563f8f 100 image_change = 1;
dkato 0:c5448e500c90 101 }
1050186 23:e7fd26563f8f 102 jcu_encoding = 0;
dkato 0:c5448e500c90 103 }
dkato 0:c5448e500c90 104
dkato 0:c5448e500c90 105 static int snapshot_req(const char ** pp_data) {
dkato 1:ebff3aeb40a0 106 int encode_size;
dkato 0:c5448e500c90 107
dkato 1:ebff3aeb40a0 108 while ((jcu_encoding == 1) || (image_change == 0)) {
1050186 23:e7fd26563f8f 109 ThisThread::sleep_for(1);
dkato 0:c5448e500c90 110 }
dkato 1:ebff3aeb40a0 111 jcu_buf_index_read = jcu_buf_index_write_done;
dkato 0:c5448e500c90 112 image_change = 0;
dkato 0:c5448e500c90 113
dkato 1:ebff3aeb40a0 114 *pp_data = (const char *)JpegBuffer[jcu_buf_index_read];
dkato 1:ebff3aeb40a0 115 encode_size = (int)jcu_encode_size[jcu_buf_index_read];
dkato 0:c5448e500c90 116
dkato 1:ebff3aeb40a0 117 return encode_size;
dkato 0:c5448e500c90 118 }
dkato 0:c5448e500c90 119
1050186 23:e7fd26563f8f 120 static void IntCallbackFunc_Vfield(DisplayBase::int_type_t int_type) {
1050186 23:e7fd26563f8f 121 if (Vfield_Int_Cnt < VFIELD_INT_SKIP_CNT) {
1050186 23:e7fd26563f8f 122 Vfield_Int_Cnt++;
1050186 23:e7fd26563f8f 123 return;
1050186 23:e7fd26563f8f 124 }
1050186 23:e7fd26563f8f 125 Vfield_Int_Cnt = 0;
1050186 23:e7fd26563f8f 126
1050186 23:e7fd26563f8f 127 //Interrupt callback function
1050186 23:e7fd26563f8f 128 if (jcu_encoding == 0) {
1050186 23:e7fd26563f8f 129 JPEG_Converter::bitmap_buff_info_t bitmap_buff_info;
1050186 23:e7fd26563f8f 130 JPEG_Converter::encode_options_t encode_options;
1050186 23:e7fd26563f8f 131
1050186 23:e7fd26563f8f 132 bitmap_buff_info.width = VIDEO_PIXEL_HW;
1050186 23:e7fd26563f8f 133 bitmap_buff_info.height = VIDEO_PIXEL_VW;
1050186 23:e7fd26563f8f 134 bitmap_buff_info.format = JPEG_Converter::WR_RD_YCbCr422;
1050186 23:e7fd26563f8f 135 bitmap_buff_info.buffer_address = (void *)user_frame_buffer0;
1050186 23:e7fd26563f8f 136
1050186 23:e7fd26563f8f 137 encode_options.encode_buff_size = sizeof(JpegBuffer[0]);
1050186 23:e7fd26563f8f 138 encode_options.p_EncodeCallBackFunc = &JcuEncodeCallBackFunc;
1050186 23:e7fd26563f8f 139 encode_options.input_swapsetting = JPEG_Converter::WR_RD_WRSWA_32_16_8BIT;
1050186 23:e7fd26563f8f 140
1050186 23:e7fd26563f8f 141 jcu_encoding = 1;
1050186 23:e7fd26563f8f 142 if (jcu_buf_index_read == jcu_buf_index_write) {
1050186 23:e7fd26563f8f 143 jcu_buf_index_write ^= 1; // toggle
1050186 23:e7fd26563f8f 144 }
1050186 23:e7fd26563f8f 145 jcu_encode_size[jcu_buf_index_write] = 0;
1050186 23:e7fd26563f8f 146 dcache_invalid(JpegBuffer[jcu_buf_index_write], sizeof(JpegBuffer[0]));
1050186 23:e7fd26563f8f 147 if (Jcu.encode(&bitmap_buff_info, JpegBuffer[jcu_buf_index_write],
1050186 23:e7fd26563f8f 148 &jcu_encode_size[jcu_buf_index_write], &encode_options) != JPEG_Converter::JPEG_CONV_OK) {
1050186 23:e7fd26563f8f 149 jcu_encode_size[jcu_buf_index_write] = 0;
1050186 23:e7fd26563f8f 150 jcu_encoding = 0;
1050186 23:e7fd26563f8f 151 }
1050186 23:e7fd26563f8f 152 }
1050186 23:e7fd26563f8f 153 }
1050186 23:e7fd26563f8f 154
1050186 23:e7fd26563f8f 155 static void Start_Video_Camera(void) {
1050186 23:e7fd26563f8f 156 // Video capture setting (progressive form fixed)
1050186 23:e7fd26563f8f 157 Display.Video_Write_Setting(
1050186 23:e7fd26563f8f 158 DisplayBase::VIDEO_INPUT_CHANNEL_0,
1050186 23:e7fd26563f8f 159 DisplayBase::COL_SYS_NTSC_358,
1050186 23:e7fd26563f8f 160 (void *)user_frame_buffer0,
1050186 23:e7fd26563f8f 161 FRAME_BUFFER_STRIDE,
1050186 23:e7fd26563f8f 162 VIDEO_FORMAT,
1050186 23:e7fd26563f8f 163 WR_RD_WRSWA,
1050186 23:e7fd26563f8f 164 VIDEO_PIXEL_VW,
1050186 23:e7fd26563f8f 165 VIDEO_PIXEL_HW
1050186 23:e7fd26563f8f 166 );
1050186 23:e7fd26563f8f 167 EasyAttach_CameraStart(Display, DisplayBase::VIDEO_INPUT_CHANNEL_0);
1050186 23:e7fd26563f8f 168 }
1050186 23:e7fd26563f8f 169
dkato 0:c5448e500c90 170 static void TerminalWrite(Arguments* arg, Reply* r) {
dkato 16:b5469a6226c7 171 if ((arg != NULL) && (r != NULL)) {
dkato 16:b5469a6226c7 172 for (int i = 0; i < arg->argc; i++) {
dkato 16:b5469a6226c7 173 if (arg->argv[i] != NULL) {
dkato 16:b5469a6226c7 174 printf("%s", arg->argv[i]);
dkato 16:b5469a6226c7 175 }
dkato 16:b5469a6226c7 176 }
dkato 16:b5469a6226c7 177 printf("\n");
dkato 16:b5469a6226c7 178 r->putData<const char*>("ok");
dkato 16:b5469a6226c7 179 }
dkato 0:c5448e500c90 180 }
dkato 0:c5448e500c90 181
dkato 0:c5448e500c90 182 static void mount_romramfs(void) {
dkato 0:c5448e500c90 183 FILE * fp;
dkato 0:c5448e500c90 184
dkato 21:c7de71ccb5ca 185 romram_bd.SetRomAddr(0x18000000, 0x1FFFFFFF);
dkato 21:c7de71ccb5ca 186 fs.format(&romram_bd, 512);
dkato 21:c7de71ccb5ca 187 fs.mount(&romram_bd);
dkato 0:c5448e500c90 188
dkato 12:6c002b871c4d 189 //index.htm
dkato 21:c7de71ccb5ca 190 fp = fopen("/storage/index.htm", "w");
dkato 12:6c002b871c4d 191 fwrite(index_htm_tbl, sizeof(char), sizeof(index_htm_tbl), fp);
dkato 12:6c002b871c4d 192 fclose(fp);
dkato 12:6c002b871c4d 193
dkato 0:c5448e500c90 194 //camera.js
dkato 21:c7de71ccb5ca 195 fp = fopen("/storage/camera.js", "w");
dkato 0:c5448e500c90 196 fwrite(camaera_js_tbl, sizeof(char), sizeof(camaera_js_tbl), fp);
dkato 0:c5448e500c90 197 fclose(fp);
dkato 0:c5448e500c90 198
dkato 0:c5448e500c90 199 //camera.htm
dkato 21:c7de71ccb5ca 200 fp = fopen("/storage/camera.htm", "w");
dkato 0:c5448e500c90 201 fwrite(camera_htm_tbl, sizeof(char), sizeof(camera_htm_tbl), fp);
dkato 0:c5448e500c90 202 fclose(fp);
dkato 0:c5448e500c90 203
dkato 0:c5448e500c90 204 //mbedrpc.js
dkato 21:c7de71ccb5ca 205 fp = fopen("/storage/mbedrpc.js", "w");
dkato 0:c5448e500c90 206 fwrite(mbedrpc_js_tbl, sizeof(char), sizeof(mbedrpc_js_tbl), fp);
dkato 0:c5448e500c90 207 fclose(fp);
dkato 0:c5448e500c90 208
dkato 0:c5448e500c90 209 //led.htm
dkato 21:c7de71ccb5ca 210 fp = fopen("/storage/led.htm", "w");
dkato 0:c5448e500c90 211 fwrite(led_htm_tbl, sizeof(char), sizeof(led_htm_tbl), fp);
dkato 0:c5448e500c90 212 fclose(fp);
1050186 5:34d84609dd60 213
1050186 5:34d84609dd60 214 //i2c_set.htm
dkato 21:c7de71ccb5ca 215 fp = fopen("/storage/i2c_set.htm", "w");
1050186 5:34d84609dd60 216 fwrite(i2c_set_htm_tbl, sizeof(char), sizeof(i2c_set_htm_tbl), fp);
1050186 5:34d84609dd60 217 fclose(fp);
1050186 5:34d84609dd60 218
1050186 5:34d84609dd60 219 //web_top.htm
dkato 21:c7de71ccb5ca 220 fp = fopen("/storage/web_top.htm", "w");
1050186 5:34d84609dd60 221 fwrite(web_top_htm_tbl, sizeof(char), sizeof(web_top_htm_tbl), fp);
1050186 5:34d84609dd60 222 fclose(fp);
1050186 5:34d84609dd60 223
1050186 5:34d84609dd60 224 //menu.htm
dkato 21:c7de71ccb5ca 225 fp = fopen("/storage/menu.htm", "w");
1050186 5:34d84609dd60 226 fwrite(menu_htm_tbl, sizeof(char), sizeof(menu_htm_tbl), fp);
1050186 5:34d84609dd60 227 fclose(fp);
1050186 5:34d84609dd60 228
1050186 5:34d84609dd60 229 //window.htm
dkato 21:c7de71ccb5ca 230 fp = fopen("/storage/window.htm", "w");
1050186 5:34d84609dd60 231 fwrite(window_htm_tbl, sizeof(char), sizeof(window_htm_tbl), fp);
1050186 5:34d84609dd60 232 fclose(fp);
1050186 5:34d84609dd60 233 }
1050186 5:34d84609dd60 234
1050186 5:34d84609dd60 235 static void SetI2CfromWeb(Arguments* arg, Reply* r) {
1050186 10:3a176dc33f74 236 int result = 0;
1050186 10:3a176dc33f74 237
1050186 10:3a176dc33f74 238 if (arg != NULL) {
1050186 10:3a176dc33f74 239 if (arg->argc >= 2) {
1050186 10:3a176dc33f74 240 if ((arg->argv[0] != NULL) && (arg->argv[1] != NULL)) {
1050186 10:3a176dc33f74 241 sprintf(i2c_setting_str_buf, "%s,%s", arg->argv[0], arg->argv[1]);
1050186 10:3a176dc33f74 242 result = 1;
1050186 10:3a176dc33f74 243 }
1050186 10:3a176dc33f74 244 } else if (arg->argc == 1) {
1050186 10:3a176dc33f74 245 if (arg->argv[0] != NULL) {
1050186 10:3a176dc33f74 246 sprintf(i2c_setting_str_buf, "%s", arg->argv[0]);
1050186 10:3a176dc33f74 247 result = 1;
1050186 10:3a176dc33f74 248 }
1050186 10:3a176dc33f74 249 } else {
1050186 10:3a176dc33f74 250 /* Do nothing */
1050186 10:3a176dc33f74 251 }
dkato 7:c45ecff1b44d 252 /* command analysis and execute */
1050186 10:3a176dc33f74 253 if (result != 0) {
1050186 10:3a176dc33f74 254 if (i2c_setting_exe(i2c_setting_str_buf) != false) {
1050186 10:3a176dc33f74 255 r->putData<const char*>(i2c_setting_str_buf);
1050186 10:3a176dc33f74 256 }
1050186 5:34d84609dd60 257 }
1050186 5:34d84609dd60 258 }
dkato 0:c5448e500c90 259 }
dkato 0:c5448e500c90 260
1050186 23:e7fd26563f8f 261 #if (SCAN_NETWORK == 1) && (NETWORK_TYPE != 3)
dkato 21:c7de71ccb5ca 262 static const char *sec2str(nsapi_security_t sec) {
dkato 21:c7de71ccb5ca 263 switch (sec) {
dkato 21:c7de71ccb5ca 264 case NSAPI_SECURITY_NONE:
dkato 21:c7de71ccb5ca 265 return "None";
dkato 21:c7de71ccb5ca 266 case NSAPI_SECURITY_WEP:
dkato 21:c7de71ccb5ca 267 return "WEP";
dkato 21:c7de71ccb5ca 268 case NSAPI_SECURITY_WPA:
dkato 21:c7de71ccb5ca 269 return "WPA";
dkato 21:c7de71ccb5ca 270 case NSAPI_SECURITY_WPA2:
dkato 21:c7de71ccb5ca 271 return "WPA2";
dkato 21:c7de71ccb5ca 272 case NSAPI_SECURITY_WPA_WPA2:
dkato 21:c7de71ccb5ca 273 return "WPA/WPA2";
dkato 21:c7de71ccb5ca 274 case NSAPI_SECURITY_UNKNOWN:
dkato 21:c7de71ccb5ca 275 default:
dkato 21:c7de71ccb5ca 276 return "Unknown";
dkato 21:c7de71ccb5ca 277 }
dkato 21:c7de71ccb5ca 278 }
dkato 21:c7de71ccb5ca 279
dkato 21:c7de71ccb5ca 280 static bool scan_network(WiFiInterface *wifi) {
dkato 21:c7de71ccb5ca 281 WiFiAccessPoint *ap;
dkato 21:c7de71ccb5ca 282 bool ret = false;
dkato 17:2648bcf3f2cc 283 int i;
1050186 23:e7fd26563f8f 284 int count = 10; /* Limit number of network arbitrary to 10 */
dkato 21:c7de71ccb5ca 285
dkato 21:c7de71ccb5ca 286 printf("Scan:\r\n");
dkato 21:c7de71ccb5ca 287 ap = new WiFiAccessPoint[count];
1050186 23:e7fd26563f8f 288 if (ap == NULL) {
1050186 23:e7fd26563f8f 289 printf("memory error\r\n");
1050186 23:e7fd26563f8f 290 return 0;
1050186 23:e7fd26563f8f 291 }
dkato 21:c7de71ccb5ca 292 count = wifi->scan(ap, count);
dkato 21:c7de71ccb5ca 293 for (i = 0; i < count; i++) {
1050186 23:e7fd26563f8f 294 printf("No.%d Network: %s secured: %s BSSID: %02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx RSSI: %hhd Ch: %hhd\r\n",
1050186 23:e7fd26563f8f 295 i, ap[i].get_ssid(), sec2str(ap[i].get_security()),
1050186 23:e7fd26563f8f 296 ap[i].get_bssid()[0], ap[i].get_bssid()[1], ap[i].get_bssid()[2], ap[i].get_bssid()[3],
1050186 23:e7fd26563f8f 297 ap[i].get_bssid()[4], ap[i].get_bssid()[5], ap[i].get_rssi(), ap[i].get_channel());
dkato 21:c7de71ccb5ca 298 }
dkato 21:c7de71ccb5ca 299 printf("%d networks available.\r\n", count);
dkato 17:2648bcf3f2cc 300
dkato 21:c7de71ccb5ca 301 if (count > 0) {
dkato 21:c7de71ccb5ca 302 char c;
dkato 21:c7de71ccb5ca 303 char pass[64];
dkato 21:c7de71ccb5ca 304 int select_no;
dkato 21:c7de71ccb5ca 305 bool loop_break = false;;
dkato 21:c7de71ccb5ca 306
dkato 21:c7de71ccb5ca 307 printf("\nPlease enter the number of the network you want to connect.\r\n");
dkato 21:c7de71ccb5ca 308 printf("Enter key:[0]-[%d], (If inputting the other key, it's scanned again.)\r\n", count - 1);
dkato 21:c7de71ccb5ca 309 c = (uint8_t)pc.getc();
dkato 21:c7de71ccb5ca 310 select_no = c - 0x30;
dkato 21:c7de71ccb5ca 311 if ((select_no >= 0) && (select_no < count)) {
dkato 21:c7de71ccb5ca 312 printf("[%s] is selected.\r\n", ap[select_no].get_ssid());
dkato 21:c7de71ccb5ca 313 printf("Please enter the PSK.\r\n");
dkato 21:c7de71ccb5ca 314 i = 0;
dkato 21:c7de71ccb5ca 315 while (loop_break == false) {
dkato 21:c7de71ccb5ca 316 c = (uint8_t)pc.getc();
dkato 21:c7de71ccb5ca 317 switch (c) {
dkato 21:c7de71ccb5ca 318 case 0x0D:
dkato 21:c7de71ccb5ca 319 pass[i] = '\0';
dkato 21:c7de71ccb5ca 320 pc.puts("\r\n");
dkato 21:c7de71ccb5ca 321 loop_break = true;
dkato 21:c7de71ccb5ca 322 break;
dkato 21:c7de71ccb5ca 323 case 0x08:
dkato 21:c7de71ccb5ca 324 if (i > 0) {
dkato 21:c7de71ccb5ca 325 pc.puts("\b \b");
dkato 21:c7de71ccb5ca 326 i--;
dkato 21:c7de71ccb5ca 327 }
dkato 21:c7de71ccb5ca 328 break;
dkato 21:c7de71ccb5ca 329 case 0x0A:
dkato 21:c7de71ccb5ca 330 break;
dkato 21:c7de71ccb5ca 331 default:
dkato 21:c7de71ccb5ca 332 if ((i + 1) < sizeof(pass)) {
dkato 21:c7de71ccb5ca 333 pass[i] = c;
dkato 21:c7de71ccb5ca 334 i++;
dkato 21:c7de71ccb5ca 335 pc.putc(c);
dkato 21:c7de71ccb5ca 336 }
dkato 21:c7de71ccb5ca 337 break;
dkato 21:c7de71ccb5ca 338 }
dkato 17:2648bcf3f2cc 339 }
dkato 21:c7de71ccb5ca 340 wifi->set_credentials(ap[select_no].get_ssid(), pass, ap[select_no].get_security());
dkato 21:c7de71ccb5ca 341 ret = true;
dkato 17:2648bcf3f2cc 342 }
dkato 17:2648bcf3f2cc 343 }
dkato 21:c7de71ccb5ca 344
dkato 21:c7de71ccb5ca 345 delete[] ap;
dkato 21:c7de71ccb5ca 346
dkato 21:c7de71ccb5ca 347 return ret;
dkato 17:2648bcf3f2cc 348 }
dkato 17:2648bcf3f2cc 349 #endif
dkato 17:2648bcf3f2cc 350
1050186 23:e7fd26563f8f 351 static void sd_connect_task(void) {
1050186 23:e7fd26563f8f 352 int storage_type = 0;
1050186 23:e7fd26563f8f 353
1050186 23:e7fd26563f8f 354 while (1) {
1050186 23:e7fd26563f8f 355 if (storage_type == 0) {
1050186 23:e7fd26563f8f 356 if (sd.connect()) {
1050186 23:e7fd26563f8f 357 fs.unmount();
1050186 23:e7fd26563f8f 358 fs.mount(&sd);
1050186 23:e7fd26563f8f 359 storage_type = 1;
1050186 23:e7fd26563f8f 360 printf("SDBlockDevice\r\n");
1050186 23:e7fd26563f8f 361 }
1050186 23:e7fd26563f8f 362 } else {
1050186 23:e7fd26563f8f 363 if (sd.connected() == false) {
1050186 23:e7fd26563f8f 364 fs.unmount();
1050186 23:e7fd26563f8f 365 fs.mount(&romram_bd);
1050186 23:e7fd26563f8f 366 storage_type = 0;
1050186 23:e7fd26563f8f 367 printf("RomRamBlockDevice\r\n");
1050186 23:e7fd26563f8f 368 }
1050186 23:e7fd26563f8f 369 }
1050186 23:e7fd26563f8f 370 ThisThread::sleep_for(250);
1050186 23:e7fd26563f8f 371 }
1050186 23:e7fd26563f8f 372 }
1050186 23:e7fd26563f8f 373
dkato 0:c5448e500c90 374 int main(void) {
dkato 0:c5448e500c90 375 printf("********* PROGRAM START ***********\r\n");
dkato 0:c5448e500c90 376
1050186 23:e7fd26563f8f 377 mount_romramfs(); //RomRamFileSystem Mount
1050186 23:e7fd26563f8f 378
1050186 23:e7fd26563f8f 379 sdConnectTask.start(&sd_connect_task);
1050186 5:34d84609dd60 380
1050186 23:e7fd26563f8f 381 EasyAttach_Init(Display);
1050186 23:e7fd26563f8f 382 Jcu.SetQuality(JPEG_ENCODE_QUALITY);
1050186 23:e7fd26563f8f 383 // Interrupt callback function setting (Field end signal for recording function in scaler 0)
1050186 23:e7fd26563f8f 384 Display.Graphics_Irq_Handler_Set(DisplayBase::INT_TYPE_S0_VFIELD, 0, IntCallbackFunc_Vfield);
1050186 23:e7fd26563f8f 385 Start_Video_Camera();
dkato 0:c5448e500c90 386
dkato 0:c5448e500c90 387 RPC::add_rpc_class<RpcDigitalOut>();
dkato 0:c5448e500c90 388 RPCFunction rpcFunc(TerminalWrite, "TerminalWrite");
1050186 5:34d84609dd60 389 RPCFunction rpcSetI2C(SetI2CfromWeb, "SetI2CfromWeb");
dkato 0:c5448e500c90 390
dkato 11:ad8ff26679bb 391 printf("Network Setting up...\r\n");
dkato 17:2648bcf3f2cc 392 #if (USE_DHCP == 0)
dkato 17:2648bcf3f2cc 393 network.set_dhcp(false);
dkato 17:2648bcf3f2cc 394 if (network.set_network(IP_ADDRESS, SUBNET_MASK, DEFAULT_GATEWAY) != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway)
dkato 17:2648bcf3f2cc 395 printf("Network Set Network Error \r\n");
dkato 0:c5448e500c90 396 }
dkato 17:2648bcf3f2cc 397 #endif
1050186 23:e7fd26563f8f 398
dkato 24:63e5f399af4a 399 #if (NETWORK_TYPE >= 2)
1050186 23:e7fd26563f8f 400 #if (SCAN_NETWORK == 1) && (NETWORK_TYPE != 3)
dkato 21:c7de71ccb5ca 401 while (!scan_network(&network));
dkato 15:eac4c3711aab 402 #else
dkato 17:2648bcf3f2cc 403 network.set_credentials(WLAN_SSID, WLAN_PSK, WLAN_SECURITY);
dkato 17:2648bcf3f2cc 404 #endif
dkato 15:eac4c3711aab 405 #endif
1050186 23:e7fd26563f8f 406
1050186 23:e7fd26563f8f 407 printf("\r\nConnecting...\r\n");
dkato 17:2648bcf3f2cc 408 if (network.connect() != 0) {
dkato 11:ad8ff26679bb 409 printf("Network Connect Error \r\n");
dkato 0:c5448e500c90 410 return -1;
dkato 0:c5448e500c90 411 }
dkato 18:0461a79ced71 412 printf("MAC Address is %s\r\n", network.get_mac_address());
dkato 17:2648bcf3f2cc 413 printf("IP Address is %s\r\n", network.get_ip_address());
dkato 17:2648bcf3f2cc 414 printf("NetMask is %s\r\n", network.get_netmask());
dkato 17:2648bcf3f2cc 415 printf("Gateway Address is %s\r\n", network.get_gateway());
dkato 11:ad8ff26679bb 416 printf("Network Setup OK\r\n");
dkato 0:c5448e500c90 417
dkato 0:c5448e500c90 418 SnapshotHandler::attach_req(&snapshot_req);
dkato 0:c5448e500c90 419 HTTPServerAddHandler<SnapshotHandler>("/camera"); //Camera
dkato 21:c7de71ccb5ca 420 FSHandler::mount("/storage", "/");
dkato 0:c5448e500c90 421 HTTPServerAddHandler<FSHandler>("/");
dkato 0:c5448e500c90 422 HTTPServerAddHandler<RPCHandler>("/rpc");
dkato 17:2648bcf3f2cc 423 HTTPServerStart(&network, 80);
dkato 0:c5448e500c90 424 }