Slide 17
Slide 17 text
Arduino Library化
2021/7/27
ESP32 SORACOM Arc
で つないでみた
• 使い方は簡単
• WireGuard型変数宣言
• NTP時刻調整
• WireGuard::begin呼び出し
• ArcのJSONに含まれている
接続情報を引数で渡す
• あとはWiFi同様に
通信処理を記述
// WireGuard configuration --- UPDATE this configuration from JSON
char private_key[] = "(Private Key) "; // [Interface] PrivateKey
IPAddress local_ip(1,2,3,4); // [Interface] Address
char public_key[] = "(Public Key)"; // [Peer] PublicKey
char endpoint_address[] = "link.arc.soracom.io"; // [Peer] Endpoint
int endpoint_port = 11010; // [Peer] Endpoint
...
static WireGuard wg;
static HTTPClient httpClient;
void setup()
{
Serial.begin(115200);
Serial.println("Connecting to the AP...");
WiFi.begin(ssid, password);
while( !WiFi.isConnected() ) {
delay(1000);
}
Serial.println("Adjusting system time...");
configTime(9 * 60 * 60, 0, "ntp.jst.mfeed.ad.jp", "ntp.nict.jp",
"time.google.com");
Serial.println("Connected. Initializing WireGuard...");
wg.begin(
local_ip,
private_key,
endpoint_address,
public_key,
endpoint_port);
}
17