3.2.8. Get RSSI (Received Signal Strength Indicator) of AP
1. If ESP8266 functions as Station and is not connected to an AP, users can obtain the
RSSI (Received Signal Strength Indicator) of an AP by scanning the AP with a specified
SSID.
Specify the SSID of the target AP:
#defineDEMO_AP_SSID“DEMO_AP"
Scan the AP with a specified SSID. After the scanning is completed, scan_done will be
called back.
structscan_configconfig;
memset(&config,0,sizeof(config));
config.ssid=DEMO_AP_SSID;
Wi-Fi_station_scan(&config,scan_done);
2. Compile the application program, generate firmware and download it into the ESP8266
module.
3. Power off the module, and change it to operation mode; then power on the module and
run the program.
Result:
Hello,welcometoscan-task!
scandone
(3,"DEMO_AP",-49,"aa:5b:78:30:46:0a",11)
3.2.9. Read and Write of Flash Memory
1. Read data from a flash memory. It is essential that the data address be four-byte
aligned. Below is an example of how to read information from a flash.
#defineSPI_FLASH_SEC_SIZE4096
uint32value;
uint8*addr=(uint8*)&value;
spi_flash_read(0x3E*SPI_FLASH_SEC_SIZE,(uint32*)addr,4);
printf("0x3Esec:%02x%02x%02x%02x\r\n",addr[0],addr[1],addr[2],addr[3]);
2. Similarly, when writing data into sectors on a flash memory, the data address should also
be four-byte aligned. Use spi_flash_erase_sector to erase the sector first, then call
spi_flash_write to write data into it. For example,
uint32data[M];
//TODO:fitinthedata
spi_flash_erase_sector(N);
spi_flash_write(N*4*1024,data,M*4);