toms.log
2021/04/19
ESP32でmDNSからIPアドレスを取得する
raspberrypi.local みたいなあれ
いちいち静的IPとかやってられないのでmDNSで名前解決してIPアドレスを取得したい. ESP32なら標準ライブラリでできる. `MDNS#queryHost` で取得できるが, 戻り値が `IPAddress` クラスなので注意. そのまま接続できるのかは不明. `HTTPClient#begin` は引数が `String` なのでとりあえず `IPAddress#toString` で渡しておけばOK.
## 参考 [ESP32でmDNSからIPアドレスを取得したい - Qiita](https://qiita.com/hanapage/items/c2df143dbde33e03e674) https://qiita.com/hanapage/items/c2df143dbde33e03e674 [arduino-esp32/libraries/ESPmDNS at master · espressif/arduino-esp32](https://github.com/espressif/arduino-esp32/tree/master/libraries/ESPmDNS) https://github.com/espressif/arduino-esp32/tree/master/libraries/ESPmDNS [arduino-esp32/IPAddress.h at master · espressif/arduino-esp32](https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/IPAddress.h) https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/IPAddress.h
1 件のコメント:
匿名
2024/03/01 23:44:00
WindowsのPCのホスト名に対しては、使えないようですね。
返信
削除
返信
返信
コメントを追加
もっと読み込む...
次の投稿
前の投稿
ホーム
登録:
コメントの投稿 (Atom)
WindowsのPCのホスト名に対しては、使えないようですね。
返信削除