
{"id":6023,"date":"2017-07-19T12:25:34","date_gmt":"2017-07-19T03:25:34","guid":{"rendered":"https:\/\/okiraku-camera.tokyo\/blog\/?p=6023"},"modified":"2017-07-19T15:18:24","modified_gmt":"2017-07-19T06:18:24","slug":"esp32%e3%81%aenvs%e3%82%92%e3%81%a1%e3%82%87%e3%81%a3%e3%81%a8%e8%a6%8b%e3%81%a6%e3%81%bf%e3%81%9f","status":"publish","type":"post","link":"https:\/\/okiraku-camera.tokyo\/blog\/?p=6023","title":{"rendered":"esp32\u306envs\u3092\u3061\u3087\u3063\u3068\u898b\u3066\u307f\u305f"},"content":{"rendered":"<h2>ESP-WROOM-32 SPI\u30d5\u30e9\u30c3\u30b7\u30e5\u306e\u30e1\u30e2\u30ea\u30de\u30c3\u30d7<\/h2>\n<p>ESP32\u30e2\u30b8\u30e5\u30fc\u30eb\u306eSPI\u30d5\u30e9\u30c3\u30b7\u30e5\u5185\u306b\u306f\u3001nvs (non volatile storage)\u3068\u547c\u3070\u308c\u308b\u9818\u57df(0x9000\u304b\u308920K\u30d0\u30a4\u30c8) \u304c\u3042\u308a\u3001\u6587\u5b57\u3069\u304a\u308a\u4e0d\u63ee\u767a\u9818\u57df\u3068\u3057\u3066\u4f7f\u308f\u308c\u3066\u3044\u308b\u3002\u30d5\u30e9\u30c3\u30b7\u30e5\u30e1\u30e2\u30ea\u306a\u306e\u3067\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u96fb\u6e90\u3092\u843d\u3068\u3057\u3066\u3082\u5185\u5bb9\u304c\u6d88\u3048\u306a\u3044\u306e\u306f\u5f53\u305f\u308a\u524d\u306a\u306e\u3060\u3051\u3069\u3001Arduino IDE\u304b\u3089\u30b9\u30b1\u30c3\u30c1\u3092\u66f8\u304d\u8fbc\u3093\u3060\u969b\u306b\u3082\u3001\u3053\u306e\u9818\u57df\u306e\u5185\u5bb9\u306f\u4e0a\u66f8\u304d\u3055\u308c\u306a\u3044\u3002\u306a\u306e\u3067\u3001\u30b9\u30b1\u30c3\u30c1\u304c\u5229\u7528\u3059\u308b\u8af8\u60c5\u5831\u3092\u3042\u3089\u304b\u3058\u3081nvs\u9818\u57df\u306b\u4ed5\u8fbc\u3093\u3067\u304a\u304d\u3001\u30b9\u30b1\u30c3\u30c1\u81ea\u4f53\u3067\u306f\u305d\u308c\u3089\u3092\u3042\u305f\u304b\u3082\u30d7\u30ed\u30d1\u30c6\u30a3\u306e\u3088\u3046\u306b\u4f7f\u3046\u3053\u3068\u304c\u3067\u304d\u308b(\u3068\u601d\u3046)\u3002<\/p>\n<p><a href=\"https:\/\/okiraku-camera.tokyo\/blog\/?p=6008\">\u4e00\u3064\u524d\u306e\u8a71<\/a>\u3067\u3001Arduino IDE\u304b\u3089\u30b3\u30f3\u30d1\u30a4\u30eb\u3057\u305f\u30b9\u30b1\u30c3\u30c1\u3092\u30d5\u30e9\u30c3\u30b7\u30e5\u306b\u66f8\u304d\u8fbc\u3080\u969b\u306b\u306f\u3001\u30b9\u30b1\u30c3\u30c1\u3092\u542b\u3081\u30664\u3064\u306e\u30d6\u30ed\u30c3\u30af\u306e\u30c7\u30fc\u30bf\u304c\u8ee2\u9001\u3055\u308c\u308b\u3068\u66f8\u3044\u305f\u306e\u3060\u3051\u3069\u3001\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30c6\u30fc\u30d6\u30eb\u306e\u5185\u5bb9\u306a\u3069\u3092\u53c2\u8003\u306b\u8ee2\u9001\u5148\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u56f3\u306b\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308b\u3002<\/p>\n<p><a href=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/07\/0d40a5e4a645fc6b96e767d64ac0878e-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-6045\" src=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/07\/0d40a5e4a645fc6b96e767d64ac0878e-5.png\" alt=\"\" width=\"432\" height=\"518\" \/><\/a><\/p>\n<p>(\u6ce8: \u73fe\u6642\u70b9\u3067\u306e\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30c6\u30fc\u30d6\u30eb(default.csv) \u306b\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u308b\u306e\u306f0x9000\u4ee5\u964d\u3060\u304c\u3001\u8ee2\u9001\u6642\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u304b\u3089\u3059\u308b\u3068\u4e0a\u8a18\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u63a8\u6e2c\u3057\u305f\u3002\u307e\u305f\u3001\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30c6\u30fc\u30d6\u30eb\u306e\u5b9a\u7fa9\u306f\u30b7\u30b9\u30c6\u30e0\u306e\u66f4\u65b0\u306b\u5fdc\u3058\u3066\u3069\u3093\u3069\u3093\u5909\u66f4\u3055\u308c\u308b\u304b\u3082\u3057\u308c\u306a\u3044)\u3002<\/p>\n<p>\u3053\u306e\u30e1\u30e2\u30ea\u30de\u30c3\u30d7\u306e\u3046\u3061\u3001nvs\u9818\u57df\u3068\u3057\u3066\u4f7f\u308f\u308c\u3066\u3044\u308b\u306e\u306f 0x9000 \u304b\u3089\u306e20K(0x5000) \u30d0\u30a4\u30c8\u306e\u3088\u3046\u3067\u3042\u308b\u3002\u30d1\u30fc\u30c6\u30a3\u30b7\u30e7\u30f3\u30c6\u30fc\u30d6\u30eb\u9818\u57df\u81ea\u4f53\u306fPC\u3067\u4f5c\u6210\u3055\u308c\u305f\u30d5\u30a1\u30a4\u30eb\u304cESP32\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u8ee2\u9001\u3055\u308c\u3066\u66f8\u304d\u8fbc\u307e\u308c\u308b\u306e\u3067\u66f4\u65b0\u3055\u308c\u308b\u304c\u3001\u8ee2\u9001\u3055\u308c\u308b\u30d0\u30a4\u30ca\u30ea\u306e\u30b5\u30a4\u30ba\u306f4K\u30d0\u30a4\u30c8\u672a\u6e80\u306a\u306e\u3067nvs\u9818\u57df\u306e\u5185\u5bb9\u304c\u4e0a\u66f8\u304d\u3055\u308c\u308b\u3053\u3068\u306f\u306a\u3044\u3002<\/p>\n<h2>nvs\u9818\u57df\u3092\u8aad\u307f\u51fa\u3057\u3066\u307f\u308b<\/h2>\n<p>nvs\u9818\u57df\u3082\u30d5\u30e9\u30c3\u30b7\u30e5\u30e1\u30e2\u30ea\u306e\u4e00\u90e8\u306a\u306e\u3067\u3001esprool\u3092\u4f7f\u3063\u3066\u8aad\u307f\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p><span class=\"striped:false nums:false wrap-toggle:false lang:default decode:true crayon-inline\">esptool.exe &#8211;port COM3 &#8211;baud 921600 read_flash 0x9000 0x5000 part.bin<\/span><\/p>\n<p>\u3092\u5b9f\u884c\u3057\u3066part.bin\u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u306b\u5438\u3044\u4e0a\u3052\u305f\u3002\u3053\u306e\u5185\u5bb9\u306e\u4e00\u90e8\u3092\u30c0\u30f3\u30d7\u3057\u3066\u307f\u308b\u3068\u3001\u6b21\u306e\u3088\u3046\u306a\u5177\u5408\u3002<a href=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/07\/0d40a5e4a645fc6b96e767d64ac0878e-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-6034\" src=\"https:\/\/okiraku-camera.tokyo\/blog\/wp-content\/uploads\/2017\/07\/0d40a5e4a645fc6b96e767d64ac0878e-3-552x287.png\" alt=\"\" width=\"552\" height=\"287\" \/><\/a><\/p>\n<p>0x00040\u4ee5\u964d\u306e32\u30d0\u30a4\u30c8\u3054\u3068\u306b\u30ad\u30fc\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3089\u3057\u304d\u3082\u306e\u304c\u5165\u3063\u3066\u3044\u308b\u3002nvs\u306e\u6982\u8981\u3001\u4f7f\u3044\u65b9\u3001\u5185\u90e8\u69cb\u9020\u306b\u3064\u3044\u3066\u306f<a href=\"https:\/\/esp-idf.readthedocs.io\/en\/v1.0\/api\/nvs_flash.html\">Non-volatile storage library<\/a> \u3068\u3044\u3046\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u30c0\u30f3\u30d7\u304b\u3089\u306f\u3001\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9&#8221;misc&#8221;\u304c\u5185\u90e8\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7 1 \u3092\u3001\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9 &#8220;nvs.net80211&#8243;\u304c\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f72 \u3092\u3082\u3063\u3066\u304a\u308a\u3001&#8221;misc&#8221;\u306b\u306f&#8221;log&#8221;\u3068\u3044\u3046\u30ad\u30fc\u6587\u5b57\u5217\u304c\u3001&#8221;nvs.net80211&#8243;\u306b\u306f\u30ad\u30fc\u540d &#8220;opmode&#8221;\u3084 &#8220;country&#8221;\u3068\u3044\u3063\u305f\u30ad\u30fc\u6587\u5b57\u5217\u304c\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u8aad\u307f\u53d6\u308c\u308b\u3002\u5185\u90e8\u89e3\u6790\u3058\u307f\u305f\u3053\u3068\u3092\u3084\u3063\u3066\u3082\u3042\u307e\u308a\u5f97\u308b\u3082\u306e\u304c\u306a\u3044\u306e\u3067\u3001nvs\u7528\u306eapi\u3092\u4f7f\u3063\u3066\u5185\u5bb9\u3092\u8aad\u307f\u51fa\u3057\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u305f\u3002<\/p>\n<p>\u4eca\u56de\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306f\u3001ESP32\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4f7f\u3044\u59cb\u3081\u305f\u3068\u304d\u304b\u3089\u6c17\u306b\u306a\u3063\u3066\u3044\u308b\u3001\u30a2\u30af\u30bb\u30b9\u30dd\u30a4\u30f3\u30c8\u540d\u3084\u30d1\u30b9\u30ef\u30fc\u30c9\u304cnvs\u306b\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3068\u3001\u30d7\u30ed\u30b0\u30e9\u30e0\u304b\u3089\u8aad\u307f\u51fa\u3057\u304c\u53ef\u80fd\u306a\u3053\u3068\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u4f5c\u6210\u3057\u305f\u3002<\/p>\n<h3>NvsDump.h<\/h3>\n<p>nvs\u5185\u306e\u6307\u5b9a\u306e\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u3001\u6307\u5b9a\u306e\u30ad\u30fc\u540d\u306e\u30c7\u30fc\u30bf\u3092blob\u578b\u3068\u3057\u3066\u8aad\u307f\u51fa\u3057\u3066\u30b7\u30ea\u30a2\u30eb\u30e2\u30cb\u30bf\u306b\u30c0\u30f3\u30d7\u3059\u308b\u3002<\/p>\n<pre class=\"lang:c++ decode:true\">#include &lt;nvs.h&gt;\r\n#include &lt;nvs_flash.h&gt;\r\n#include \"esp_err.h\"\r\n\r\nclass NvsDump {\r\n  nvs_handle h;\r\n  bool got_handle = false;\r\n  esp_err_t last_err;\r\n  size_t blob_bytes = 0;\r\n  char* pblob = 0;\r\n\r\npublic:\r\n  NvsDump(const char* name) {\r\n    nvs_flash_init();\r\n    if ((last_err = nvs_open(name,  NVS_READONLY, &amp;h)) != ESP_OK) {\r\n      Serial.print(\"nvs_open failed. return \");\r\n      Serial.println(last_err, 16);\r\n    } else\r\n      got_handle = true;\r\n  }\r\n\r\n  ~NvsDump() {\r\n    clear();\r\n    if (got_handle)\r\n      nvs_close(h);\r\n  }\r\n\r\n  void clear() {\r\n    if (pblob)\r\n      free(pblob);\r\n    pblob = 0;\r\n    blob_bytes = 0;    \r\n  }\r\n\r\n  static String bin2hex(byte b) {\r\n    static const char* cp = \"0123456789abcdef\";\r\n    return  String(cp[(b &gt;&gt; 4) &amp; 0xf]) + String(cp[(b &amp; 0xf)]);\r\n  }\r\n\r\n  void dump_blob() {\r\n    if (!pblob || blob_bytes &lt; 1)\r\n      return;    \r\n    int index = 0;\r\n    String hexes = \"\";\r\n    String chars = \"\";\r\n    while( index &lt; blob_bytes ) {\r\n      byte b = pblob[index];\r\n      hexes += bin2hex(b);\r\n      if (b &gt; 0x1f &amp;&amp; b &lt; 0x80)\r\n        chars += String(pblob[index]);\r\n      else\r\n        chars += \".\";\r\n      hexes += \" \";\r\n      index++;\r\n      if (index % 16 == 0 || index == blob_bytes) {\r\n        if (index % 16 != 0) {\r\n          for(int i = 0; i &lt; 16 - (index % 16); i++) {\r\n            hexes += \"   \";\r\n            chars += \" \";                              \r\n          }\r\n        }\r\n        Serial.print(hexes);\r\n        Serial.print(\"   \");\r\n        Serial.println(chars);            \r\n        hexes = \"\";\r\n        chars = \"\";\r\n      }\r\n    }\r\n  }\r\n\r\n  bool read_blob(const char* key)  {\r\n    clear();\r\n    if ((last_err = nvs_get_blob(h, key, NULL, &amp;blob_bytes)) != ESP_OK) {\r\n      Serial.print(\"nvs_get_blob \" + String(key) + \" failed. return \");\r\n      Serial.println(last_err, 16);\r\n      return false;\r\n    }\r\n    Serial.print(\"nvs_get_blob( \" + String(key) + \" ) return \");\r\n    Serial.println(String(blob_bytes) + \" bytes\");\r\n  \r\n    pblob = (char*)malloc(blob_bytes);\r\n    if (pblob) {\r\n      if ((last_err = nvs_get_blob(h, key, pblob, &amp;blob_bytes)) == ESP_OK)\r\n        return true;      \r\n      Serial.print(\"nvs_get_blob failed. return \");\r\n      Serial.println(last_err, 16);\r\n      clear();\r\n   }\r\n   return false;\r\n }\r\n};<\/pre>\n<p>nvs_open() \u3092 NVS_READONLY \u4ee5\u5916\u3067\u547c\u3076\u3068\u3001\u5b58\u5728\u3057\u306a\u3044\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u3092\u6307\u5b9a\u3057\u305f\u308a\u3001\u5b58\u5728\u3057\u306a\u3044\u30ad\u30fc\u540d\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u3069\u3093\u3069\u3093\u4f5c\u3089\u308c\u3066\u3057\u307e\u3046\u304b\u3082\u3057\u308c\u306a\u3044\u3053\u3068\u306b\u6ce8\u610f\u304c\u5fc5\u8981\u3002<\/p>\n<p>\u3053\u306e\u30af\u30e9\u30b9\u3092\u4f7f\u3046\u5b9f\u88c5\u5074\u3068\u3057\u3066\u3001WIFI\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u3068\u3057\u3066\u6307\u5b9a\u3057\u305f\u30a2\u30af\u30bb\u30b9\u30dd\u30a4\u30f3\u30c8\u306b\u63a5\u7d9a\u3059\u308b\u3060\u3051\u306e\u30b9\u30b1\u30c3\u30c1\u3092\u7528\u610f\u3057\u305f\u3002<\/p>\n<h3>ESP32_WIFI_STA1.ino<\/h3>\n<p>\u3053\u306e\u30b9\u30b1\u30c3\u30c1\u3092NvsDump.h\u3068\u540c\u3058\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u7f6e\u3044\u3066\u304a\u304d\u3001Arduino IDE\u3067\u958b\u304f\u30682\u3064\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u304a\u306e\u304a\u306e\u30bd\u30fc\u30b9\u30bf\u30d6\u3068\u3057\u3066\u8868\u793a\u3055\u308c\u308b\u306e\u3067\u3001\u9078\u629e\/\u7de8\u96c6\u304c\u5bb9\u6613\u306b\u3067\u304d\u308b\u3002<\/p>\n<pre class=\"lang:c++ decode:true\">\/\/ esp32 wifi sta\r\n\r\n#include &lt;WiFi.h&gt;\r\n#include \"NvsDump.h\"\r\n\r\nbool connect_to_ap() {\r\n  WiFi.begin(\"AndroidAP\", \"esp32passwd\");\r\n  int n = 0;\r\n  int counter = 0;\r\n  while ((n = WiFi.status()) != WL_CONNECTED) {\r\n    Serial.print(String(n) + \" \");\r\n    delay(400);\r\n    if (counter++ &gt; 25) {\r\n      Serial.println(\"\\nwifi-connect failed\\nprintDiag()\\n\");\r\n      WiFi.printDiag(Serial);\r\n      return false;\r\n    }\r\n  }\r\n  return true;  \r\n}\r\n\r\nvoid setup() {\r\n  NvsDump nvs(\"nvs.net80211\");\r\n  \r\n  Serial.begin(115200);\r\n  delay(10);\r\n  Serial.println(\"\");\r\n\r\n  WiFi.mode(WIFI_STA);\r\n  WiFi.setAutoConnect(false);\r\n  if (connect_to_ap()) {\r\n    Serial.println(\"\\nconnected. WiFi.printDiag()\\n\");\r\n    WiFi.printDiag(Serial);\r\n    Serial.println(WiFi.localIP().toString());\r\n  }    \r\n  Serial.println(\"\");\r\n\r\n  if (nvs.read_blob(\"ap.mac\"))\r\n    nvs.dump_blob();\r\n  if (nvs.read_blob(\"ap.ssid\"))\r\n    nvs.dump_blob();\r\n  if (nvs.read_blob(\"ap.passwd\"))\r\n    nvs.dump_blob();\r\n\r\n  if (nvs.read_blob(\"sta.mac\"))\r\n    nvs.dump_blob();\r\n  if (nvs.read_blob(\"sta.ssid\"))\r\n    nvs.dump_blob();\r\n  if (nvs.read_blob(\"sta.pswd\"))\r\n    nvs.dump_blob();\r\n}\r\n\r\nvoid loop() {\r\n  delay(10);\r\n}<\/pre>\n<p>\u6307\u5b9a\u306e\u30a2\u30af\u30bb\u30b9\u30dd\u30a4\u30f3\u30c8(\u4eca\u56de\u306f\u3001Android\u30b9\u30de\u30db\u306eWiFI\u30c6\u30a3\u30b6\u30ea\u30f3\u30b0\u6a5f\u80fd\u3092\u4f7f\u3063\u305f)\u306b\u63a5\u7d9a\u3057\u3001\u305d\u306e\u72b6\u614b\u3067\u95a2\u4fc2\u3042\u308a\u305d\u3046\u306a\u9805\u76ee\u3092nvs\u304b\u3089\u8aad\u307f\u51fa\u3057\u3066\u30b7\u30ea\u30a2\u30eb\u30e2\u30cb\u30bf\u306b\u8868\u793a\u3059\u308b\u3002\u3053\u306e\u30b9\u30b1\u30c3\u30c1\u3067\u306fWIFI_STA\u30e2\u30fc\u30c9\u3057\u304b\u4f7f\u308f\u306a\u3044\u304c\u3001\u524d\u56de\u66f8\u3044\u305f\u30b9\u30b1\u30c3\u30c1\u3067\u306e\u30a2\u30af\u30bb\u30b9\u30dd\u30a4\u30f3\u30c8\u60c5\u5831\u3082\u8aad\u307f\u51fa\u3057\u3066\u307f\u305f\u3002<\/p>\n<pre class=\"font:courier-new striped:false lang:default decode:true\">255 [D][WiFiGeneric.cpp:182] _eventCallback(): Event: 2 - STA_START\r\n6 6 [D][WiFiGeneric.cpp:182] _eventCallback(): Event: 4 - STA_CONNECTED\r\n[D][WiFiGeneric.cpp:182] _eventCallback(): Event: 7 - STA_GOT_IP\r\n\r\nconnected. WiFi.printDiag()\r\n\r\nMode: STA\r\nChannel: 6\r\nAuto connect: 0\r\nSSID (9): AndroidAP\r\nPassphrase (11): esp32passwd\r\nBSSID set: 0\r\n192.168.43.170\r\n\r\nnvs_get_blob( ap.mac ) return 6 bytes\r\n30 ae a4 05 62 f5                                  0...b.          \r\nnvs_get_blob( ap.ssid ) return 36 bytes\r\n07 00 00 00 45 53 50 33 32 41 50 00 d0 cc fc 3f    ....ESP32AP....?\r\n00 00 00 00 00 00 00 00 00 00 00 00 11 1c 08 40    ...............@\r\n03 00 00 00                                        ....            \r\nnvs_get_blob( ap.passwd ) return 65 bytes\r\n70 61 73 73 77 6f 72 64 00 00 00 00 00 00 00 00    password........\r\n00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................\r\n00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................\r\n00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................\r\n00                                                 .               \r\nnvs_get_blob( sta.mac ) return 6 bytes\r\n30 ae a4 05 62 f4                                  0...b.          \r\nnvs_get_blob( sta.ssid ) return 36 bytes\r\n09 00 00 00 41 6e 64 72 6f 69 64 41 50 00 fc 3f    ....AndroidAP..?\r\n40 a3 fc 3f 01 00 00 00 9e 6d 0f 80 00 cc fc 3f    @..?.....m.....?\r\n10 00 00 00                                        ....            \r\nnvs_get_blob( sta.pswd ) return 65 bytes\r\n65 73 70 33 32 70 61 73 73 77 64 00 00 00 00 00    esp32passwd.....\r\n00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................\r\n00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................\r\n00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................\r\n00<\/pre>\n<p>\u4e0a\u8a18\u306e\u3088\u3046\u306b\u3001WIFI_STA\u3067\u306e\u63a5\u7d9a\u60c5\u5831\u3060\u3051\u3067\u306f\u306a\u304f\u3001\u5225\u306e\u30b9\u30b1\u30c3\u30c1\u3067\u66f8\u3044\u305fWIFI_AP\u7528\u306e\u8a2d\u5b9a\u60c5\u5831(ap.ssid\u3068ap.passwd)\u3082\u3061\u3083\u3093\u3068\u6b8b\u3063\u3066\u307e\u3057\u305f\u3002<\/p>\n<p>\u3055\u3089\u306b\u3001\u4e0b\u8a18\u306e\u3088\u3046\u306anvs\u5185\u5bb9\u306e\u8868\u793a\u3060\u3051\u3092\u884c\u3046\u30b9\u30b1\u30c3\u30c1\u3092\u5b9f\u884c\u3057\u3066\u3082\u3001\u30b7\u30ea\u30a2\u30eb\u30e2\u30cb\u30bf\u306b\u306f\u540c\u3058\u5185\u5bb9\u304c\u8868\u793a\u3055\u308c\u308b\u3002<\/p>\n<pre class=\"lang:c++ decode:true\">#include \"NvsDump.h\"\r\n\r\nvoid setup() {\r\n  NvsDump nvs(\"nvs.net80211\");\r\n\r\n  Serial.begin(115200);\r\n  delay(10);\r\n  Serial.println(\"\");\r\n\r\n  if (nvs.read_blob(\"ap.mac\"))\r\n    nvs.dump_blob();\r\n  if (nvs.read_blob(\"ap.ssid\"))\r\n    nvs.dump_blob();\r\n  if (nvs.read_blob(\"ap.passwd\"))\r\n    nvs.dump_blob();\r\n\r\n  if (nvs.read_blob(\"sta.mac\"))\r\n    nvs.dump_blob();\r\n  if (nvs.read_blob(\"sta.ssid\"))\r\n    nvs.dump_blob();\r\n  if (nvs.read_blob(\"sta.pswd\"))\r\n    nvs.dump_blob();\r\n}\r\n\r\nvoid loop() {\r\n  delay(10);\r\n}<\/pre>\n<p>\u5148\u306e\u66f8\u3044\u305f\u65b9\u306e ESP32_WIFI_STA1.ino \u3068\u3044\u3046\u30b9\u30b1\u30c3\u30c1\u3067\u306f\u3001<span class=\"lang:c++ decode:true crayon-inline\">WiFi.setAutoConnect(false);<\/span> \u306b\u3088\u3063\u3066\u30ea\u30b9\u30bf\u30fc\u30c8\u6642\u306e\u81ea\u52d5\u63a5\u7d9a\u3092\u7981\u6b62\u3057\u3066\u3044\u308b\u304c\u3001\u81ea\u52d5\u63a5\u7d9a\u3092\u8a31\u53ef\u3057\u3066\u3044\u308b\u5834\u5408\u306fnvs\u304b\u3089\u63a5\u7d9a\u5148\u60c5\u5831\u3092\u8aad\u307f\u51fa\u3057\u3066\u81ea\u52d5\u63a5\u7d9a\u3059\u308b\u3068\u601d\u308f\u308c\u308b\u3002<\/p>\n<h2>\u304d\u3087\u3046\u306e\u307e\u3068\u3081<\/h2>\n<p>nvs api\u306b\u306f\u4fdd\u5b58\u3055\u308c\u3066\u3044\u308b\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u306e\u4e00\u89a7\u3084\u3001\u3042\u308b\u30cd\u30fc\u30e0\u30b9\u30da\u30fc\u30b9\u306b\u767b\u9332\u3055\u308c\u3066\u3044\u308b\u30ad\u30fc\u540d\u306e\u4e00\u89a7\u3092\u5f97\u308b\u65b9\u6cd5\u304c\u306a\u3044\u3002\u3057\u3087\u3046\u304c\u306a\u3044\u306e\u3067\u6700\u521d\u306b\u5438\u3044\u4e0a\u3052\u305f part.bin \u306e\u30c0\u30f3\u30d7\u304b\u3089\u305d\u308c\u3089\u3057\u3044\u3082\u306e\u3092\u63a2\u3057\u3066\u4f7f\u3063\u305f\u3002<\/p>\n<p>\u540c\u3058\u6a5f\u80fd\u3092\u3082\u3064\u304c\u63a5\u7d9a\u5148AP\u540d\u304c\u3044\u308d\u3044\u308d\u306aWiFi\u30b9\u30c6\u30fc\u30b7\u30e7\u30f3\u3060\u3063\u305f\u308a\u3001\u540c\u3058\u5834\u6240\u306bWIFI_AP\u6a5f\u80fd\u3092\u3082\u3064\u8907\u6570\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u914d\u7f6e\u3059\u308b\u3088\u3046\u306a\u5834\u5408\u3001nvs\u3092\u5916\u304b\u3089\u66f8\u304d\u63db\u3048\u308b\u65b9\u6cd5\u3060\u3051\u8003\u3048\u3066\u304a\u3051\u3070\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u7528\u306b\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u4f7f\u3046\u3053\u3068\u3082\u306a\u3044\u3057\u3001\u30b9\u30b1\u30c3\u30c1\u3082\u4e00\u3064\u3067\u6e08\u3080\u304b\u3089\u697d\u304b\u3082\u3057\u308c\u306a\u3044\u3002\u4f55\u304b\u601d\u3044\u3064\u3044\u305f\u3089\u4f7f\u3063\u3066\u307f\u308b\u3053\u3068\u306b\u3057\u3088\u3046\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>ESP-WROOM-32 SPI\u30d5\u30e9\u30c3\u30b7\u30e5\u306e\u30e1\u30e2\u30ea\u30de\u30c3\u30d7 ESP32\u30e2\u30b8\u30e5\u30fc\u30eb\u306eSPI\u30d5\u30e9\u30c3\u30b7\u30e5\u5185\u306b\u306f\u3001nvs (non volatile storage)\u3068\u547c\u3070\u308c\u308b\u9818\u57df(0x9000\u304b\u308920K\u30d0\u30a4\u30c8) \u304c\u3042\u308a\u3001\u6587\u5b57\u3069\u304a &hellip; <a href=\"https:\/\/okiraku-camera.tokyo\/blog\/?p=6023\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">esp32\u306envs\u3092\u3061\u3087\u3063\u3068\u898b\u3066\u307f\u305f<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69],"tags":[65,84],"class_list":["post-6023","post","type-post","status-publish","format-standard","hentry","category-programming","tag-arduino","tag-esp32"],"_links":{"self":[{"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6023"}],"version-history":[{"count":0,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=\/wp\/v2\/posts\/6023\/revisions"}],"wp:attachment":[{"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/okiraku-camera.tokyo\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}