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.
Fork of cc3000_hostdriver_mbedsocket by
cc3000_netapp.cpp
00001 /***************************************************************************** 00002 * 00003 * C++ interface/implementation created by Martin Kojtal (0xc0170). Thanks to 00004 * Jim Carver and Frank Vannieuwkerke for their inital cc3000 mbed port and 00005 * provided help. 00006 * 00007 * This version of "host driver" uses CC3000 Host Driver Implementation. Thus 00008 * read the following copyright: 00009 * 00010 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, are permitted provided that the following conditions 00014 * are met: 00015 * 00016 * Redistributions of source code must retain the above copyright 00017 * notice, this list of conditions and the following disclaimer. 00018 * 00019 * Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in the 00021 * documentation and/or other materials provided with the 00022 * distribution. 00023 * 00024 * Neither the name of Texas Instruments Incorporated nor the names of 00025 * its contributors may be used to endorse or promote products derived 00026 * from this software without specific prior written permission. 00027 * 00028 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00029 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00030 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00031 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00032 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00033 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00034 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00035 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00036 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00037 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00038 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00039 * 00040 *****************************************************************************/ 00041 #include "cc3000.h" 00042 #include "cc3000_netapp.h" 00043 00044 namespace mbed_cc3000 { 00045 00046 cc3000_netapp::cc3000_netapp(cc3000_simple_link &simple_link, cc3000_nvmem &nvmem, cc3000_hci &hci , cc3000_event &event) : 00047 _simple_link(simple_link), _nvmem(nvmem), _hci(hci), _event(event) { 00048 00049 } 00050 00051 cc3000_netapp::~cc3000_netapp() { 00052 00053 } 00054 00055 int32_t cc3000_netapp::config_mac_adrress(uint8_t * mac) { 00056 return _nvmem.set_mac_address(mac); 00057 } 00058 00059 int32_t cc3000_netapp::dhcp(uint32_t *ip, uint32_t *subnet_mask,uint32_t *default_gateway, uint32_t *dns_server) { 00060 int8_t scRet; 00061 uint8_t *ptr; 00062 uint8_t *args; 00063 00064 scRet = EFAIL; 00065 ptr = _simple_link.get_transmit_buffer(); 00066 args = (ptr + HEADERS_SIZE_CMD); 00067 00068 // Fill in temporary command buffer 00069 ARRAY_TO_STREAM(args,ip,4); 00070 ARRAY_TO_STREAM(args,subnet_mask,4); 00071 ARRAY_TO_STREAM(args,default_gateway,4); 00072 args = UINT32_TO_STREAM(args, 0); 00073 ARRAY_TO_STREAM(args,dns_server,4); 00074 00075 // Initiate a HCI command 00076 _hci.command_send(HCI_NETAPP_DHCP, ptr, NETAPP_DHCP_PARAMS_LEN); 00077 00078 // Wait for command complete event 00079 _event.simplelink_wait_event(HCI_NETAPP_DHCP, &scRet); 00080 00081 return scRet; 00082 } 00083 00084 #ifndef CC3000_TINY_DRIVER 00085 void cc3000_netapp::ipconfig( tNetappIpconfigRetArgs * ipconfig ) { 00086 uint8_t *ptr; 00087 00088 ptr = _simple_link.get_transmit_buffer(); 00089 00090 // Initiate a HCI command 00091 _hci.command_send(HCI_NETAPP_IPCONFIG, ptr, 0); 00092 00093 // Wait for command complete event 00094 _event.simplelink_wait_event(HCI_NETAPP_IPCONFIG, ipconfig ); 00095 } 00096 00097 00098 int32_t cc3000_netapp::timeout_values(uint32_t *dhcp, uint32_t *arp,uint32_t *keep_alive, uint32_t *inactivity) { 00099 int8_t scRet; 00100 uint8_t *ptr; 00101 uint8_t *args; 00102 00103 scRet = EFAIL; 00104 ptr = _simple_link.get_transmit_buffer(); 00105 args = (ptr + HEADERS_SIZE_CMD); 00106 00107 // Set minimal values of timers 00108 MIN_TIMER_SET(*dhcp) 00109 MIN_TIMER_SET(*arp) 00110 MIN_TIMER_SET(*keep_alive) 00111 MIN_TIMER_SET(*inactivity) 00112 00113 // Fill in temporary command buffer 00114 args = UINT32_TO_STREAM(args, *dhcp); 00115 args = UINT32_TO_STREAM(args, *arp); 00116 args = UINT32_TO_STREAM(args, *keep_alive); 00117 args = UINT32_TO_STREAM(args, *inactivity); 00118 00119 // Initiate a HCI command 00120 _hci.command_send(HCI_NETAPP_SET_TIMERS, ptr, NETAPP_SET_TIMER_PARAMS_LEN); 00121 00122 // Wait for command complete event 00123 _event.simplelink_wait_event(HCI_NETAPP_SET_TIMERS, &scRet); 00124 00125 return scRet; 00126 } 00127 00128 int32_t cc3000_netapp::ping_send(uint32_t *ip, uint32_t ping_attempts, uint32_t ping_size, uint32_t ping_timeout) { 00129 int8_t scRet; 00130 uint8_t *ptr, *args; 00131 00132 scRet = EFAIL; 00133 ptr = _simple_link.get_transmit_buffer(); 00134 args = (ptr + HEADERS_SIZE_CMD); 00135 00136 // Fill in temporary command buffer 00137 args = UINT32_TO_STREAM(args, *ip); 00138 args = UINT32_TO_STREAM(args, ping_attempts); 00139 args = UINT32_TO_STREAM(args, ping_size); 00140 args = UINT32_TO_STREAM(args, ping_timeout); 00141 00142 // Initiate a HCI command 00143 _hci.command_send(HCI_NETAPP_PING_SEND, ptr, NETAPP_PING_SEND_PARAMS_LEN); 00144 00145 // Wait for command complete event 00146 _event.simplelink_wait_event(HCI_NETAPP_PING_SEND, &scRet); 00147 00148 return scRet; 00149 } 00150 00151 void cc3000_netapp::ping_report() { 00152 uint8_t *ptr; 00153 int8_t scRet; 00154 ptr = _simple_link.get_transmit_buffer(); 00155 00156 00157 scRet = EFAIL; 00158 00159 // Initiate a HCI command 00160 _hci.command_send(HCI_NETAPP_PING_REPORT, ptr, 0); 00161 00162 // Wait for command complete event 00163 _event.simplelink_wait_event(HCI_NETAPP_PING_REPORT, &scRet); 00164 } 00165 00166 int32_t cc3000_netapp::ping_stop() { 00167 int8_t scRet; 00168 uint8_t *ptr; 00169 00170 scRet = EFAIL; 00171 ptr = _simple_link.get_transmit_buffer(); 00172 00173 // Initiate a HCI command 00174 _hci.command_send(HCI_NETAPP_PING_STOP, ptr, 0); 00175 00176 // Wait for command complete event 00177 _event.simplelink_wait_event(HCI_NETAPP_PING_STOP, &scRet); 00178 00179 return scRet; 00180 } 00181 00182 int32_t cc3000_netapp::arp_flush() { 00183 int8_t scRet; 00184 uint8_t *ptr; 00185 00186 scRet = EFAIL; 00187 ptr = _simple_link.get_transmit_buffer(); 00188 00189 // Initiate a HCI command 00190 _hci.command_send(HCI_NETAPP_ARP_FLUSH, ptr, 0); 00191 00192 // Wait for command complete event 00193 _event.simplelink_wait_event(HCI_NETAPP_ARP_FLUSH, &scRet); 00194 00195 return scRet; 00196 } 00197 #endif 00198 00199 } // mbed_cc3000
Generated on Fri Jul 15 2022 17:19:25 by
 1.7.2
 1.7.2 
    