Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: JSON M2XStreamClient-JMF WNCInterface mbed-rtos mbed
You are viewing an older revision! See the latest version
README
This example program uses the WDCInterface Library (a Wistron NeWeb Corporation (WNC) M14A2A Series data module) on the AT&T Cellular IoT Starter Kit which is sold by Avnet.
NOTE: This example is specific to the AT&T Cellular IoT Starter Kit which uses a FRDM-K64F. The users mbed.org compiler should be configured to use the FRDM-K64F platform.
DESCRIPTION¶
The Socket Example Program Implements a:
TCP Socket¶
The TCP socket example issues a GET request to the mbed.org server to get the hello.txt followed by a read. The received file is then displayed to the user.
UDP Socket¶
The UDP Socket example will send a test string to a designated UDP URL, and will then read back from that UDP port and report how many characters were read.
HTTPClient socket¶
The HTTPClient example issues a series of commands; a GET, POST, PUT, and DELETE. The GET command will retrieve the same hello.txt file that was used in the TCP Socket example. The POST, PUT, and DELETE commands all use http://httpbin.org. When written to httpbin.org, the command will be echoed back to the sender and displayed for the user to review.
Discussion¶
The HTTP example program exercises the Sockets interface in three ways:
1. The hello.txt file that is displayed to the user is:
HTTP/1.1 200 OK Server: nginx/1.7.10 Date: Mon, 12 Sep 2016 19:35:31 GMT Content-Type: text/plain Content-Length: 14 Connection: close Last-Modified: Fri, 27 Jul 2012 13:30:34 GMT Accept-Ranges: bytes Cache-Control: max-age=36000 Expires: Tue, 13 Sep 2016 05:35:31 GMT X-Upstream-L3: 172.17.0.4:80 X-Upstream-L2: developer-sjc-cyan-1-nginx X-Upstream-L1-next-hop: 217.140.101.22:8001 X-Upstream-L1: developer-sjc-cyan-border-nginx Hello world!
2. Using the utcnist.colorado.edc
as the UDP URL with a generic message, the response will be:
starting UDP Socket Test... Endpoing set to 'utcnist.colorado.edu'/128.138.140.44/37, try sending data. sent buffer to UDP IP/Port (ret=5) Now try receiving. Received 0 bytes via UDP IP address 128.138.140.44 on port 37: 0 seconds since 1/01/1900 00:00 GMT
3. The HTTP Client functionality is demonstrated by:
3.1 The GET call using http.get returns the same hello.txt file used above but only the message body is displayed:
>>>>Fetch a page... Page fetched successfully - read 14 characters <-----> Result: Hello world! <----->
3.2) issuing a POST call using http.post to post to httpbin.org, the server responds by echoing the POST call back. The response should look like:
Result: { "args": {}, "data": "", "files": {}, "form": { "Hello": "World", "test": "1234" }, "headers": { "Content-Length": "21", "Content-Type": "application/x-www-form-urlencoded", "Host": "httpbin.org" }, "json": null, "origin": "204.16.69.130", "url": "http://httpbin.org/post" }
3.3) issuing a PUT call using http.put to httpbin.org results in a response similar to:
Result: { "args": {}, "data": "This is a PUT test!", "files": {}, "form": {}, "headers": { "Content-Length": "19", "Content-Type": "text/plain", "Host": "httpbin.org" }, "json": null, "origin": "204.16.69.130", "url": "http://httpbin.org/put" }
3.4 Performing a http.delete to httpbin.org responds similar to:
Result: { "args": {}, "data": "", "files": {}, "form": {}, "headers": { "Host": "httpbin.org" }, "json": null, "origin": "204.16.69.130", "url": "http://httpbin.org/delete" }
License
This library is released under the Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License and may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.