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.
Dependents: cc3000_hello_world_demo cc3000_simple_socket_demo cc3000_ntp_demo cc3000_ping_demo ... more
cc3000_client.cpp@8:4c42ca37ba33, 2013-09-30 (annotated)
- Committer:
- Kojto
- Date:
- Mon Sep 30 19:29:06 2013 +0000
- Revision:
- 8:4c42ca37ba33
- Parent:
- 0:615c697c33b0
- Child:
- 20:30b6ed7bf8fd
Endpoint::set_address correction with IP returned from gethostbyname; Socket - sock_fd set to -1 when socket is closed (still not handling return type. Will add later)
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Kojto | 0:615c697c33b0 | 1 | /***************************************************************************** |
| Kojto | 0:615c697c33b0 | 2 | * |
| Kojto | 0:615c697c33b0 | 3 | * C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to |
| Kojto | 0:615c697c33b0 | 4 | * Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and |
| Kojto | 0:615c697c33b0 | 5 | * provided help. |
| Kojto | 0:615c697c33b0 | 6 | * |
| Kojto | 0:615c697c33b0 | 7 | * This version of "host driver" uses CC3000 Host Driver Implementation. Thus |
| Kojto | 0:615c697c33b0 | 8 | * read the following copyright: |
| Kojto | 0:615c697c33b0 | 9 | * |
| Kojto | 0:615c697c33b0 | 10 | * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ |
| Kojto | 0:615c697c33b0 | 11 | * |
| Kojto | 0:615c697c33b0 | 12 | * Redistribution and use in source and binary forms, with or without |
| Kojto | 0:615c697c33b0 | 13 | * modification, are permitted provided that the following conditions |
| Kojto | 0:615c697c33b0 | 14 | * are met: |
| Kojto | 0:615c697c33b0 | 15 | * |
| Kojto | 0:615c697c33b0 | 16 | * Redistributions of source code must retain the above copyright |
| Kojto | 0:615c697c33b0 | 17 | * notice, this list of conditions and the following disclaimer. |
| Kojto | 0:615c697c33b0 | 18 | * |
| Kojto | 0:615c697c33b0 | 19 | * Redistributions in binary form must reproduce the above copyright |
| Kojto | 0:615c697c33b0 | 20 | * notice, this list of conditions and the following disclaimer in the |
| Kojto | 0:615c697c33b0 | 21 | * documentation and/or other materials provided with the |
| Kojto | 0:615c697c33b0 | 22 | * distribution. |
| Kojto | 0:615c697c33b0 | 23 | * |
| Kojto | 0:615c697c33b0 | 24 | * Neither the name of Texas Instruments Incorporated nor the names of |
| Kojto | 0:615c697c33b0 | 25 | * its contributors may be used to endorse or promote products derived |
| Kojto | 0:615c697c33b0 | 26 | * from this software without specific prior written permission. |
| Kojto | 0:615c697c33b0 | 27 | * |
| Kojto | 0:615c697c33b0 | 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| Kojto | 0:615c697c33b0 | 29 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| Kojto | 0:615c697c33b0 | 30 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| Kojto | 0:615c697c33b0 | 31 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| Kojto | 0:615c697c33b0 | 32 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| Kojto | 0:615c697c33b0 | 33 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| Kojto | 0:615c697c33b0 | 34 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| Kojto | 0:615c697c33b0 | 35 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| Kojto | 0:615c697c33b0 | 36 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| Kojto | 0:615c697c33b0 | 37 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| Kojto | 0:615c697c33b0 | 38 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| Kojto | 0:615c697c33b0 | 39 | * |
| Kojto | 0:615c697c33b0 | 40 | *****************************************************************************/ |
| Kojto | 0:615c697c33b0 | 41 | #include "cc3000.h" |
| Kojto | 0:615c697c33b0 | 42 | |
| Kojto | 0:615c697c33b0 | 43 | namespace mbed_cc3000 { |
| Kojto | 0:615c697c33b0 | 44 | |
| Kojto | 0:615c697c33b0 | 45 | |
| Kojto | 0:615c697c33b0 | 46 | cc3000_client::cc3000_client(cc3000 &cc3000_ref) : _cc3000(cc3000_ref) { |
| Kojto | 0:615c697c33b0 | 47 | _current_socket = -1; |
| Kojto | 0:615c697c33b0 | 48 | } |
| Kojto | 0:615c697c33b0 | 49 | |
| Kojto | 0:615c697c33b0 | 50 | cc3000_client::cc3000_client(cc3000 &cc3000_ref, int16_t socket) : _cc3000(cc3000_ref) { |
| Kojto | 0:615c697c33b0 | 51 | _current_socket = socket; |
| Kojto | 0:615c697c33b0 | 52 | } |
| Kojto | 0:615c697c33b0 | 53 | |
| Kojto | 0:615c697c33b0 | 54 | bool cc3000_client::connected(void) { |
| Kojto | 0:615c697c33b0 | 55 | if (_current_socket < 0) { |
| Kojto | 0:615c697c33b0 | 56 | return false; |
| Kojto | 0:615c697c33b0 | 57 | } |
| Kojto | 0:615c697c33b0 | 58 | |
| Kojto | 0:615c697c33b0 | 59 | return true; |
| Kojto | 0:615c697c33b0 | 60 | } |
| Kojto | 0:615c697c33b0 | 61 | |
| Kojto | 0:615c697c33b0 | 62 | int16_t cc3000_client::write(const void *buffer, uint16_t length, uint32_t flags = 0) { |
| Kojto | 0:615c697c33b0 | 63 | return _cc3000._socket.send(_current_socket, buffer, length, flags); |
| Kojto | 0:615c697c33b0 | 64 | } |
| Kojto | 0:615c697c33b0 | 65 | |
| Kojto | 0:615c697c33b0 | 66 | int16_t cc3000_client::read(void *buffer, uint16_t length, uint32_t flags) |
| Kojto | 0:615c697c33b0 | 67 | { |
| Kojto | 0:615c697c33b0 | 68 | return _cc3000._socket.recv(_current_socket, buffer, length, flags); |
| Kojto | 0:615c697c33b0 | 69 | |
| Kojto | 0:615c697c33b0 | 70 | } |
| Kojto | 0:615c697c33b0 | 71 | |
| Kojto | 0:615c697c33b0 | 72 | } /* end of mbed_cc3000 namespace */ |
SimpleLink Wi-Fi CC3000
Avnet Wi-Go System