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:
Wed Sep 07 08:28:18 2016 +0000
Revision:
17:493d36f1febf
Parent:
8:3711d702305e
Change to wifi AP mode.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:c5448e500c90 1 /*******************************************************************************
dkato 0:c5448e500c90 2 * DISCLAIMER
dkato 0:c5448e500c90 3 * This software is supplied by Renesas Electronics Corporation and is only
dkato 0:c5448e500c90 4 * intended for use with Renesas products. No other uses are authorized. This
dkato 0:c5448e500c90 5 * software is owned by Renesas Electronics Corporation and is protected under
dkato 0:c5448e500c90 6 * all applicable laws, including copyright laws.
dkato 0:c5448e500c90 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
dkato 0:c5448e500c90 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
dkato 0:c5448e500c90 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
dkato 0:c5448e500c90 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
dkato 0:c5448e500c90 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
dkato 0:c5448e500c90 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
dkato 0:c5448e500c90 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
dkato 0:c5448e500c90 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
dkato 0:c5448e500c90 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
dkato 0:c5448e500c90 16 * Renesas reserves the right, without notice, to make changes to this software
dkato 0:c5448e500c90 17 * and to discontinue the availability of this software. By using this software,
dkato 0:c5448e500c90 18 * you agree to the additional terms and conditions found by accessing the
dkato 0:c5448e500c90 19 * following link:
dkato 0:c5448e500c90 20 * http://www.renesas.com/disclaimer*
dkato 0:c5448e500c90 21 * Copyright (C) 2015 Renesas Electronics Corporation. All rights reserved.
dkato 0:c5448e500c90 22 *******************************************************************************/
dkato 0:c5448e500c90 23 #ifndef MBED_ROMRAMFILESYSTEM_H
dkato 0:c5448e500c90 24 #define MBED_ROMRAMFILESYSTEM_H
dkato 0:c5448e500c90 25
dkato 0:c5448e500c90 26 #include "FATFileSystem.h"
dkato 0:c5448e500c90 27
dkato 0:c5448e500c90 28 #define NUM_OF_SECTORS (1000)
dkato 0:c5448e500c90 29 #define SECTOR_SIZE (512)
dkato 0:c5448e500c90 30
dkato 0:c5448e500c90 31 #if defined(TARGET_RZ_A1H)
dkato 0:c5448e500c90 32 #define ROM_START_ADDRESS (0x18000000uL) // for GR-PEACH
dkato 0:c5448e500c90 33 #define ROM_END_ADDRESS (0x1FFFFFFFuL) // for GR-PEACH
dkato 0:c5448e500c90 34 #else
dkato 0:c5448e500c90 35 #define ROM_START_ADDRESS (0xFFFFFFFFuL)
dkato 0:c5448e500c90 36 #define ROM_END_ADDRESS (0xFFFFFFFFuL)
dkato 0:c5448e500c90 37 #endif
dkato 0:c5448e500c90 38
dkato 0:c5448e500c90 39 using namespace mbed;
dkato 0:c5448e500c90 40
dkato 0:c5448e500c90 41 class RomRamFileSystem : public FATFileSystem {
dkato 0:c5448e500c90 42 public:
dkato 0:c5448e500c90 43 // NUM_OF_SECTORS sectors, each 512 bytes
dkato 0:c5448e500c90 44 char *sectors[NUM_OF_SECTORS];
dkato 0:c5448e500c90 45
dkato 0:c5448e500c90 46 RomRamFileSystem(const char* name) : FATFileSystem(name) {
dkato 0:c5448e500c90 47 memset(sectors, 0, sizeof(sectors));
dkato 0:c5448e500c90 48 }
dkato 0:c5448e500c90 49
dkato 0:c5448e500c90 50 virtual ~RomRamFileSystem() {
dkato 0:c5448e500c90 51 for (int i = 0; i < NUM_OF_SECTORS; i++) {
dkato 0:c5448e500c90 52 if ((sectors[i] != NULL) && (isRomAddress(sectors[i]) == false)) {
dkato 0:c5448e500c90 53 free(sectors[i]);
dkato 0:c5448e500c90 54 }
dkato 0:c5448e500c90 55 }
dkato 0:c5448e500c90 56 }
dkato 0:c5448e500c90 57
dkato 0:c5448e500c90 58 // read a sector in to the buffer, return 0 if ok
1050186 8:3711d702305e 59 virtual int disk_read(uint8_t *buffer, uint32_t sector, uint32_t count) {
dkato 0:c5448e500c90 60 for (uint64_t sec_no = sector; sec_no < (sector + count); sec_no++) {
dkato 0:c5448e500c90 61 if (sectors[sec_no] == NULL) {
dkato 0:c5448e500c90 62 // nothing allocated means sector is empty
dkato 0:c5448e500c90 63 memset(buffer, 0, SECTOR_SIZE);
dkato 0:c5448e500c90 64 } else {
dkato 0:c5448e500c90 65 memcpy(buffer, sectors[sec_no], SECTOR_SIZE);
dkato 0:c5448e500c90 66 }
dkato 0:c5448e500c90 67 buffer += SECTOR_SIZE;
dkato 0:c5448e500c90 68 }
dkato 0:c5448e500c90 69 return 0;
dkato 0:c5448e500c90 70 }
dkato 0:c5448e500c90 71
dkato 0:c5448e500c90 72 // write a sector from the buffer, return 0 if ok
1050186 8:3711d702305e 73 virtual int disk_write(const uint8_t *buffer, uint32_t sector, uint32_t count) {
dkato 0:c5448e500c90 74 for (uint64_t sec_no = sector; sec_no < (sector + count); sec_no++) {
dkato 0:c5448e500c90 75 bool all_zero = true;
dkato 0:c5448e500c90 76 for (int i = 0; i < SECTOR_SIZE; i++) {
dkato 0:c5448e500c90 77 if (buffer[i] != NULL) {
dkato 0:c5448e500c90 78 all_zero = false;
dkato 0:c5448e500c90 79 break;
dkato 0:c5448e500c90 80 }
dkato 0:c5448e500c90 81 }
dkato 0:c5448e500c90 82 if (all_zero != false) {
dkato 0:c5448e500c90 83 if (sectors[sec_no] != NULL) {
dkato 0:c5448e500c90 84 if (isRomAddress(sectors[sec_no]) == false) {
dkato 0:c5448e500c90 85 free(sectors[sec_no]);
dkato 0:c5448e500c90 86 }
dkato 0:c5448e500c90 87 sectors[sec_no] = NULL;
dkato 0:c5448e500c90 88 }
dkato 0:c5448e500c90 89 return 0;
dkato 0:c5448e500c90 90 }
dkato 0:c5448e500c90 91 // allocate a sector if needed, and write
dkato 0:c5448e500c90 92 if (isRomAddress((char *)buffer) == false) {
dkato 0:c5448e500c90 93 if ((sectors[sec_no] == NULL) || (isRomAddress(sectors[sec_no]) != false)) {
dkato 0:c5448e500c90 94 char *sec = (char*)malloc(SECTOR_SIZE);
dkato 0:c5448e500c90 95 if (sec == NULL) {
dkato 0:c5448e500c90 96 return 1; // out of memory
dkato 0:c5448e500c90 97 }
dkato 0:c5448e500c90 98 sectors[sec_no] = sec;
dkato 0:c5448e500c90 99 }
dkato 0:c5448e500c90 100 memcpy(sectors[sec_no], buffer, SECTOR_SIZE);
dkato 0:c5448e500c90 101 } else {
dkato 0:c5448e500c90 102 if (isRomAddress(sectors[sec_no]) == false) {
dkato 0:c5448e500c90 103 free(sectors[sec_no]);
dkato 0:c5448e500c90 104 }
dkato 0:c5448e500c90 105 sectors[sec_no] = (char *)buffer;
dkato 0:c5448e500c90 106 }
dkato 0:c5448e500c90 107 buffer += SECTOR_SIZE;
dkato 0:c5448e500c90 108 }
dkato 0:c5448e500c90 109 return 0;
dkato 0:c5448e500c90 110 }
dkato 0:c5448e500c90 111
dkato 0:c5448e500c90 112 // return the number of sectors
1050186 8:3711d702305e 113 virtual uint32_t disk_sectors() {
dkato 0:c5448e500c90 114 return NUM_OF_SECTORS;
dkato 0:c5448e500c90 115 }
dkato 0:c5448e500c90 116
dkato 0:c5448e500c90 117 void dump(FILE *fp) {
dkato 0:c5448e500c90 118 for (int i = 0; i < NUM_OF_SECTORS; i++) {
dkato 0:c5448e500c90 119 fwrite(&sectors[i], sizeof(int), 1, fp);
dkato 0:c5448e500c90 120 if (sectors[i] != NULL) {
dkato 0:c5448e500c90 121 fwrite(sectors[i], sizeof(char), SECTOR_SIZE, fp);
dkato 0:c5448e500c90 122 }
dkato 0:c5448e500c90 123 }
dkato 0:c5448e500c90 124 }
dkato 0:c5448e500c90 125
dkato 0:c5448e500c90 126 void load(FILE *fp) {
dkato 0:c5448e500c90 127 int sec_info = 0;
dkato 0:c5448e500c90 128 for (int i = 0; i < NUM_OF_SECTORS; i++) {
dkato 0:c5448e500c90 129 fread(&sec_info, sizeof(int), 1, fp);
dkato 0:c5448e500c90 130 if (sec_info != 0) {
dkato 0:c5448e500c90 131 char *sec = (char *)malloc(SECTOR_SIZE);
dkato 0:c5448e500c90 132 fread(sec, sizeof(char), SECTOR_SIZE, fp);
dkato 0:c5448e500c90 133 sectors[i] = sec;
dkato 0:c5448e500c90 134 }
dkato 0:c5448e500c90 135 }
dkato 0:c5448e500c90 136 }
dkato 0:c5448e500c90 137
dkato 0:c5448e500c90 138 private:
dkato 0:c5448e500c90 139 bool isRomAddress(char * address) {
dkato 0:c5448e500c90 140 if (((uint32_t)address >= ROM_START_ADDRESS)
dkato 0:c5448e500c90 141 && ((uint32_t)address <= (ROM_END_ADDRESS - SECTOR_SIZE + 1))) {
dkato 0:c5448e500c90 142 return true;
dkato 0:c5448e500c90 143 }
dkato 0:c5448e500c90 144 return false;
dkato 0:c5448e500c90 145 }
dkato 0:c5448e500c90 146 };
dkato 0:c5448e500c90 147 #endif