Web Camera for mbed-os. 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 LWIPBP3595Interface_STA_for_mbed-os RomRamBlockDevice mbed-rpc

Fork of GR-Boards_WebCamera by Renesas

このサンプルは 「GR-LYCHEE」ではじめる電子工作 で紹介しています。
出版時と内容が異ならないよう、各ライブラリはアップデートせずに使用してください。

このサンプルの最新バージョンは下記から入手できます。最新バージョンは本の内容と一部処理が異なります。
https://github.com/d-kato/GR-Boards_WebCamera

Files at this revision

API Documentation at this revision

Comitter:
dkato
Date:
Fri Oct 28 06:33:08 2016 +0000
Parent:
16:b5469a6226c7
Child:
18:0461a79ced71
Commit message:
Change for the mbed-os.

Changed in this revision

EthernetInterface.lib Show diff for this revision Revisions of this file
FATFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
GR-PEACH_WlanBP3595STA.lib Show diff for this revision Revisions of this file
GR-PEACH_video.lib Show annotated file Show diff for this revision Revisions of this file
GraphicsFramework.lib Show annotated file Show diff for this revision Revisions of this file
HttpServer_snapshot.lib Show diff for this revision Revisions of this file
HttpServer_snapshot_mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
LWIPBP3595Interface_mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
--- a/EthernetInterface.lib	Thu Jun 02 05:39:35 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/EthernetInterface/#183490eb1b4a
--- a/FATFileSystem.lib	Thu Jun 02 05:39:35 2016 +0000
+++ b/FATFileSystem.lib	Fri Oct 28 06:33:08 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/mbed-official/code/FATFileSystem/#094f84646b9f
+http://developer.mbed.org/teams/mbed-official/code/FATFileSystem/#e2ab678eb692
--- a/GR-PEACH_WlanBP3595STA.lib	Thu Jun 02 05:39:35 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/teams/Rohm/code/GR-PEACH_WlanBP3595STA/#14efbf8a07ea
--- a/GR-PEACH_video.lib	Thu Jun 02 05:39:35 2016 +0000
+++ b/GR-PEACH_video.lib	Fri Oct 28 06:33:08 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Renesas/code/GR-PEACH_video/#e0e475089616
+http://developer.mbed.org/teams/Renesas/code/GR-PEACH_video/#aeefe5171463
--- a/GraphicsFramework.lib	Thu Jun 02 05:39:35 2016 +0000
+++ b/GraphicsFramework.lib	Fri Oct 28 06:33:08 2016 +0000
@@ -1,1 +1,1 @@
-http://developer.mbed.org/teams/Renesas/code/GraphicsFramework/#5a1c5bffebce
+http://developer.mbed.org/teams/Renesas/code/GraphicsFramework/#df2bc72f7fb7
--- a/HttpServer_snapshot.lib	Thu Jun 02 05:39:35 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-https://developer.mbed.org/teams/Renesas/code/HttpServer_snapshot/#4ab2f287d06d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HttpServer_snapshot_mbed-os.lib	Fri Oct 28 06:33:08 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/Renesas/code/HttpServer_snapshot_mbed-os/#0700755d64ae
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LWIPBP3595Interface_mbed-os.lib	Fri Oct 28 06:33:08 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/dkato/code/LWIPBP3595Interface_STA_for_mbed-os/#0c32d38d4322
--- a/main.cpp	Thu Jun 02 05:39:35 2016 +0000
+++ b/main.cpp	Fri Oct 28 06:33:08 2016 +0000
@@ -24,9 +24,10 @@
 #endif
 #define NETWORK_TYPE           (0)                 /* Select  0(EthernetInterface) or 1(GR_PEACH_WlanBP3595) */
 #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_WPA2 /* NSAPI_SECURITY_NONE, NSAPI_SECURITY_WEP, NSAPI_SECURITY_WPA or NSAPI_SECURITY_WPA2 */
+  #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
 /** Camera setting **/
 #define VIDEO_INPUT_METHOD     (VIDEO_CMOS_CAMERA) /* Select  VIDEO_CVBS or VIDEO_CMOS_CAMERA                       */
@@ -61,13 +62,14 @@
   #include "EthernetInterface.h"
   EthernetInterface network;
 #elif (NETWORK_TYPE == 1)
-  #include "GR_PEACH_WlanBP3595.h"
-  GR_PEACH_WlanBP3595 network;
+  #include "LWIPBP3595Interface.h"
+  LWIPBP3595Interface network;
   DigitalOut usb1en(P3_8);
 #else
   #error NETWORK_TYPE error
 #endif /* NETWORK_TYPE */
 RomRamFileSystem romramfs("romram");
+Serial pc(USBTX, USBRX);
 
 #if defined(__ICCARM__)
 #pragma data_alignment=16
@@ -382,6 +384,92 @@
     }
 }
 
+#if (SCAN_NETWORK == 1)
+static void scan_network(void) {
+    int num;
+    int i;
+    int select_no;
+    bool loop_break;
+    char ch;
+    char pass[64];
+    const uint8_t *wk_p;
+    WiFiAccessPoint point[8];
+
+    while (1) {
+        printf("scan...\n");
+        num = network.scan(point, 8);
+        for (i = 0; i < num; i++) {
+            printf(" No.%d\n", i);
+            printf("   ssid    :%s\n", point[i].get_ssid());
+            wk_p = point[i].get_bssid();
+            printf("   bssid   :0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x\n",
+                    wk_p[0],wk_p[1],wk_p[2],wk_p[3],wk_p[4],wk_p[5]);
+            printf("   security:");
+            switch (point[i].get_security()) {
+                case NSAPI_SECURITY_NONE:
+                    printf("NONE\n");
+                    break;
+                case NSAPI_SECURITY_WPA:
+                    printf("WPA\n");
+                    break;
+                case NSAPI_SECURITY_WPA2:
+                    printf("WPA2\n");
+                    break;
+                case NSAPI_SECURITY_WPA_WPA2:
+                    printf("WPA_WPA2\n");
+                    break;
+                case NSAPI_SECURITY_UNKNOWN:
+                default:
+                    printf("UNKNOWN\n");
+                    break;
+            }
+            printf("   rssi    :%d\n", point[i].get_rssi());
+            printf("   channel :%d\n", point[i].get_channel());
+        }
+        if (num > 0) {
+            printf("\nPlease enter the number of the network you want to connect.\n");
+            printf("Enter key:[0]-[%d], (If inputting the other key, it's scanned again.)\n", num - 1);
+            ch = (uint8_t)pc.getc();
+            select_no = ch - 0x30;
+            if ((select_no >= 0) && (select_no < num)) {
+                printf("[%s] is selected.\n", point[select_no].get_ssid());
+                printf("Please enter the PSK.\n");
+                loop_break = false;
+                i = 0;
+                while (loop_break == false) {
+                    ch = (uint8_t)pc.getc();
+                    switch (ch) {
+                        case 0x0D:
+                            pass[i] = '\0';
+                            pc.puts("\r\n");
+                            loop_break = true;
+                            break;
+                        case 0x08:
+                            if (i > 0) {
+                                pc.puts("\b \b");
+                                i--;
+                            }
+                            break;
+                        case 0x0A:
+                            break;
+                        default:
+                            if ((i + 1) < sizeof(pass)) {
+                                pass[i] = ch;
+                                i++;
+                                pc.putc(ch);
+                            }
+                            break;
+                    }
+                }
+                printf("connecting...\n");
+                network.set_credentials(point[select_no].get_ssid(), pass, point[select_no].get_security());
+                break;
+            }
+        }
+    }
+}
+#endif
+
 int main(void) {
     printf("********* PROGRAM START ***********\r\n");
 
@@ -407,26 +495,31 @@
 #endif
 
     printf("Network Setting up...\r\n");
-#if (USE_DHCP == 1)
-    if (network.init() != 0) {                             //for DHCP Server
-#else
-    if (network.init(IP_ADDRESS, SUBNET_MASK, DEFAULT_GATEWAY) != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway)
-#endif
-        printf("Network Initialize Error \r\n");
+#if (USE_DHCP == 0)
+    network.set_dhcp(false);
+    if (network.set_network(IP_ADDRESS, SUBNET_MASK, DEFAULT_GATEWAY) != 0) { //for Static IP Address (IPAddress, NetMasks, Gateway)
+        printf("Network Set Network Error \r\n");
         return -1;
     }
-#if (NETWORK_TYPE == 0)
-    if (network.connect() != 0) {
+#endif
+
+#if (NETWORK_TYPE == 1)
+#if (SCAN_NETWORK == 1)
+    scan_network();
 #else
-    if (network.connect(WLAN_SSID, WLAN_PSK, WLAN_SECURITY) != 0) {
+    network.set_credentials(WLAN_SSID, WLAN_PSK, WLAN_SECURITY);
+#endif
 #endif
+
+    if (network.connect() != 0) {
         printf("Network Connect Error \r\n");
         return -1;
     }
-    printf("MAC Address is %s\r\n", network.getMACAddress());
-    printf("IP Address is %s\r\n", network.getIPAddress());
-    printf("NetMask is %s\r\n", network.getNetworkMask());
-    printf("Gateway Address is %s\r\n", network.getGateway());
+
+    printf("MbsAC Address is %s\r\n", network.get_mac_address());
+    printf("IP Address is %s\r\n", network.get_ip_address());
+    printf("NetMask is %s\r\n", network.get_netmask());
+    printf("Gateway Address is %s\r\n", network.get_gateway());
     printf("Network Setup OK\r\n");
 
     SnapshotHandler::attach_req(&snapshot_req);
@@ -434,5 +527,5 @@
     FSHandler::mount("/romram", "/");
     HTTPServerAddHandler<FSHandler>("/");
     HTTPServerAddHandler<RPCHandler>("/rpc");
-    HTTPServerStart(80);
+    HTTPServerStart(&network, 80);
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-os.lib	Fri Oct 28 06:33:08 2016 +0000
@@ -0,0 +1,1 @@
+https://github.com/ARMmbed/mbed-os/#e2617cc0e17f5c3fc2bae6a589c9bcfd3d1a717b
--- a/mbed-rtos.lib	Thu Jun 02 05:39:35 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#4c105b8d7cae
--- a/mbed.bld	Thu Jun 02 05:39:35 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file