当方のWindows10 PCにて、HTTPリクエストが受信できるスタブ環境(node.jsで作成)で、ESP32からPOSTリクエストできるかパケットキャプチャで確認しながら試してみました。
(MOTU実機は所有していないので、スタブが返却するレスポンスの結果内容は適当です。)
結論から言うと、お試しになったArduinoのソースコードでESP32からPOSTリクエストは相手の宛先・ポートが合っていれば通りますね。
Error on sending PUT Request: -5
は、当方では再現が出来ませんでした。
- パケットキャプチャの内容
Hypertext Transfer Protocol
POST /datastore/ext/obank/2/ch/0/name HTTP/1.1\r\n
Host: 192.168.0.1\r\n
User-Agent: ESP32HTTPClient\r\n
Connection: keep-alive\r\n
Accept-Encoding: identity;q=1,chunked;q=0.1,*;q=0\r\n
Content-Type: application/json\r\n
Content-Length: 31\r\n
\r\n
[Full request URI: http://192.168.0.1/datastore/ext/obank/2/ch/0/name]
[HTTP request 1/1]
[Response in frame: 193836]
File Data: 31 bytes
JavaScript Object Notation: application/json
Object
Member Key: value
String value: My favorite channel
Key: value
- 正常なリクエストの場合
200
{
"data": [
{
"name": "tts",
"type": 1
}
],
"result": 1,
"success": true
}
- リクエスト結果が異常の場合
Connected to WiFi network with IP Address: 192.168.0.75
Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.
404
{}
- 相手の宛先・ポートが間違っている場合
Connected to WiFi network with IP Address: 192.168.0.75
Timer set to 5 seconds (timerDelay variable), it will take 5 seconds before publishing the first reading.
Error on sending PUT Request: -1
以上、参考になれば幸いです。