Added mutex for multiple SPI devices on the same SPI bus
Fork of cc3000_hostdriver_mbedsocket by
Diff: cc3000.h
- Revision:
- 34:1ad18123bf11
- Parent:
- 33:9e23b24fb4f3
- Child:
- 35:9dd909fb7caf
--- a/cc3000.h Tue Oct 08 07:04:07 2013 +0200
+++ b/cc3000.h Tue Oct 08 13:13:05 2013 +0200
@@ -339,83 +339,95 @@
public:
/**
* \brief
- * \param
- * \return
+ * \param simplelink Reference to simple link object.
+ * \param hci Reference to hci object.
+ * \param spi Reference to spi object.
+ * \param cc3000 Reference to cc3000 object.
+ * \return none
*/
cc3000_event(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_spi &spi, cc3000 &cc3000);
/**
- * \brief
- * \param
- * \return
+ * \brief Ctor
+ * \param none
+ * \return none
*/
~cc3000_event();
- /**
- * \brief
- * \param
- * \return
+ /**
+ * \brief Handle unsolicited event from type patch request.
+ * \param event_hdr event header
+ * \return none
*/
void hci_unsol_handle_patch_request(uint8_t *event_hdr);
/**
- * \brief
- * \param
- * \return
- */
+ * \brief Parse the incoming event packets and issue corresponding event handler from global array of handlers pointers.
+ * \param ret_param incoming data buffer
+ * \param from from information (in case of data received)
+ * \param fromlen from information length (in case of data received)
+ * \return none
+ */
uint8_t *hci_event_handler(void *ret_param, uint8_t *from, uint8_t *fromlen);
/**
- * \brief
- * \param
- * \return
- */
+ * \brief Handle unsolicited events.
+ * \param event_hdr Event header
+ * \return 1 if event supported and handled
+ * \return 0 if event is not supported
+ */
int32_t hci_unsol_event_handler(uint8_t *event_hdr);
/**
- * \brief
- * \param
- * \return
- */
+ * \brief Parse the incoming unsolicited event packets and start corresponding event handler.
+ * \param None
+ * \return ESUCCESS if successful, EFAIL if an error occurred.
+ */
int32_t hci_unsolicited_event_handler(void);
/**
- * \brief
- * \param
- * \return
- */
+ * \brief Get the socket status.
+ * \param Sd Socket IS
+ * \return Current status of the socket.
+ */
int32_t get_socket_active_status(int32_t sd);
/**
- * \brief
- * \param
- * \return
- */
+ * \brief Check if the socket ID and status are valid and set the global socket status accordingly.
+ * \param Sd Sock descr
+ * \param Status status to be set
+ * \return none
+ */
void set_socket_active_status(int32_t sd, int32_t status);
/**
- * \brief
- * \param
- * \return
- */
+ * \brief Keep track on the number of packets transmitted and update the number of free buffer in the SL device.
+ * \brief Called when unsolicited event = HCI_EVNT_DATA_UNSOL_FREE_BUFF has received.
+ * \param event pointer to the string contains parameters for IPERF.
+ * \return ESUCCESS if successful, EFAIL if an error occurred.
+ */
int32_t hci_event_unsol_flowcontrol_handler(uint8_t *event);
/**
- * \brief
- * \param
- * \return
- */
+ * \brief Update the socket status.
+ * \param resp_params Socket IS
+ * \return Current status of the socket.
+ */
void update_socket_active_status(uint8_t *resp_params);
/**
- * \brief
- * \param
- * \return
+ * \brief Wait for event, pass it to the hci_event_handler and update the event opcode in a global variable.
+ * \param op_code Command operation code
+ * \param ret_param Command return parameters
+ * \return none
*/
void simplelink_wait_event(uint16_t op_code, void *ret_param);
/**
- * \brief
- * \param
- * \return
+ * \brief Wait for data, pass it to the hci_event_handler and set the data available flag.
+ * \param buffer Data buffer
+ * \param from From information
+ * \param fromlen From information length
+ * \return none
*/
void simplelink_wait_data(uint8_t *buffer, uint8_t *from, uint8_t *fromlen);
/**
- * \brief
- * \param
- * \return
+ * \brief Trigger Received event/data processing - called from the SPI library to receive the data
+ * \param buffer pointer to the received data buffer\n
+ * The function triggers Received event/data processing\n
+ * \return none
*/
void received_handler(uint8_t *buffer);
- private:
+private:
uint32_t socket_active_status;
cc3000_simple_link &_simple_link;
cc3000_hci &_hci;
@@ -428,64 +440,148 @@
class cc3000_netapp {
public:
/**
- * \brief
- * \param
- * \return
+ * \brief Ctor
+ * \param simple_link Reference to the simple link object.
+ * \param nvmem Reference to the nvmem object.
+ * \param hci Reference to the hci object.
+ * \param event Reference to the event object.
+ * \return none
*/
cc3000_netapp(cc3000_simple_link &simple_link, cc3000_nvmem &nvmem, cc3000_hci &hci, cc3000_event &event);
/**
- * \brief
- * \param
- * \return
+ * \brief Dtor
+ * \param none
+ * \return none
*/
~cc3000_netapp();
/**
- * \brief
- * \param
- * \return
+ * \brief Configure device MAC address and store it in NVMEM.
+ * The value of the MAC address configured through the API will be\n
+ * stored in CC3000 non volatile memory, thus preserved over resets.\n
+ * \param mac device mac address, 6 bytes. Saved: yes
+ * \return return on success 0, otherwise error.
*/
int32_t config_mac_adrress(uint8_t *mac);
/**
- * \brief
- * \param
- * \return
+ * \brief Configure the network interface, static or dynamic (DHCP).
+ * In order to activate DHCP mode, ip, subnet_mask, default_gateway must be 0.\n
+ * The default mode of CC3000 is DHCP mode. The configuration is saved in non volatile memory\n
+ * and thus preserved over resets.\n
+ * \param ip device mac address, 6 bytes. Saved: yes
+ * \param subnet_mask device mac address, 6 bytes. Saved: yes
+ * \param default_gateway device mac address, 6 bytes. Saved: yes
+ * \param dns_server device mac address, 6 bytes. Saved: yes
+ * \return 0 on success, otherwise error.
+ * \note If the mode is altered, a reset of CC3000 device is required to apply the changes.\n
+ * Also note that an asynchronous event of type 'DHCP_EVENT' is generated only when\n
+ * a connection to the AP was established. This event is generated when an IP address\n
+ * is allocated either by the DHCP server or by static allocation.\n
*/
int32_t dhcp(uint32_t *ip, uint32_t *subnet_mask,uint32_t *default_gateway, uint32_t *dns_server);
#ifndef CC3000_TINY_DRIVER
/**
- * \brief
- * \param
- * \return
+ * \brief Get the CC3000 Network interface information.
+ * This information is only available after establishing a WLAN connection.\n
+ * Undefined values are returned when this function is called before association.\n
+ * \param ipconfig pointer to a tNetappIpconfigRetArgs structure for storing the network interface configuration.\n
+ * tNetappIpconfigRetArgs: aucIP - ip address,\n
+ * aucSubnetMask - mask
+ * aucDefaultGateway - default gateway address\n
+ * aucDHCPServer - dhcp server address\n
+ * aucDNSServer - dns server address\n
+ * uaMacAddr - mac address\n
+ * uaSSID - connected AP ssid\n
+ * \return none
+ * \note This function is useful for figuring out the IP Configuration of\n
+ * the device when DHCP is used and for figuring out the SSID of\n
+ * the Wireless network the device is associated with.\n
*/
void ipconfig(tNetappIpconfigRetArgs *ipconfig);
/**
- * \brief
- * \param
- * \return
+ * \brief Set new timeout values for DHCP lease timeout, ARP refresh timeout, keepalive event timeout and socket inactivity timeout
+ * \param dhcp DHCP lease time request, also impact\n
+ * the DHCP renew timeout.\n
+ * Range: [0-0xffffffff] seconds,\n
+ * 0 or 0xffffffff = infinite lease timeout.\n
+ * Resolution: 10 seconds.\n
+ * Influence: only after reconnecting to the AP. \n
+ * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds.\n
+ * The parameter is saved into the CC3000 NVMEM.\n
+ * The default value on CC3000 is 14400 seconds.\n
+ *
+ * \param arp ARP refresh timeout, if ARP entry is not updated by\n
+ * incoming packet, the ARP entry will be deleted by\n
+ * the end of the timeout. \n
+ * Range: [0-0xffffffff] seconds, 0 = infinite ARP timeout\n
+ * Resolution: 10 seconds.\n
+ * Influence: at runtime.\n
+ * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds\n
+ * The parameter is saved into the CC3000 NVMEM.\n
+ * The default value on CC3000 is 3600 seconds.\n
+ *
+ * \param keep_alive Keepalive event sent by the end of keepalive timeout\n
+ * Range: [0-0xffffffff] seconds, 0 == infinite timeout\n
+ * Resolution: 10 seconds.\n
+ * Influence: at runtime.\n
+ * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec\n
+ * The parameter is saved into the CC3000 NVMEM. \n
+ * The default value on CC3000 is 10 seconds.\n
+ *
+ * \param inactivity Socket inactivity timeout, socket timeout is\n
+ * refreshed by incoming or outgoing packet, by the\n
+ * end of the socket timeout the socket will be closed\n
+ * Range: [0-0xffffffff] sec, 0 == infinite timeout.\n
+ * Resolution: 10 seconds.\n
+ * Influence: at runtime.\n
+ * Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec\n
+ * The parameter is saved into the CC3000 NVMEM.\n
+ * The default value on CC3000 is 60 seconds.\n
+ *
+ * \return 0 on success,otherwise error.
+ *
+ * \note A parameter set to a non zero value less than 20s automatically changes to 20s.
*/
int32_t timeout_values(uint32_t *dhcp, uint32_t *arp,uint32_t *keep_alive, uint32_t *inactivity);
/**
- * \brief
- * \param
- * \return
+ * \brief send ICMP ECHO_REQUEST to network hosts
+ * \param ip destination IP address
+ * \param ping_attempts number of echo requests to send
+ * \param ping_size send buffer size which may be up to 1400 bytes
+ * \param ping_timeout Time to wait for a response,in milliseconds.
+ * \return 0 on success, otherwise error.
+ *
+ * \note A succesful operation will generate an asynchronous ping report event.\n
+ * The report structure is defined by structure netapp_pingreport_args_t.\n
+ * \warning Calling this function while a Ping Request is in progress will kill the ping request in progress.
*/
int32_t ping_send(uint32_t *ip, uint32_t ping_attempts, uint32_t ping_size, uint32_t ping_timeout);
/**
- * \brief
- * \param
- * \return
+ * \brief Ping status request.
+ * This API triggers the CC3000 to send asynchronous events: HCI_EVNT_WLAN_ASYNC_PING_REPORT.\n
+ * This event will create the report structure in netapp_pingreport_args_t.\n
+ * This structure is filled with ping results until the API is triggered.\n
+ * netapp_pingreport_args_t: packets_sent - echo sent\n
+ * packets_received - echo reply\n
+ * min_round_time - minimum round time\n
+ * max_round_time - max round time\n
+ * avg_round_time - average round time\n
+ *
+ * \param none
+ * \return none
+ * \note When a ping operation is not active, the returned structure fields are 0.
*/
void ping_report();
/**
- * \brief
- * \param
- * \return
+ * \brief Stop any ping request.
+ * \param none
+ * \return 0 on success
+ * -1 on error
*/
int32_t ping_stop();
/**
- * \brief
- * \param
- * \return
+ * \brief Flush ARP table
+ * \param none
+ * \return none
*/
int32_t arp_flush();
#endif
@@ -502,51 +598,81 @@
class cc3000_security {
public:
/**
- * \brief
- * \param
- * \return
+ * \brief Expand a 16 bytes key for AES128 implementation.
+ * \param expanded_key expanded AES128 key
+ * \param key AES128 key - 16 bytes
+ * \return none
*/
void expandKey(uint8_t *expanded_key, uint8_t *key);
/**
- * \brief
- * \param
- * \return
+ * \brief multiply by 2 in the galois field.
+ * \param value Argument to multiply
+ * \return multiplied argument
*/
uint8_t galois_mul2(uint8_t value);
/**
- * \brief
- * \param
- * \return
+ * \brief internal implementation of AES128 encryption.
+ * straight forward aes encryption implementation\n
+ * first the group of operations
+ * - addRoundKey
+ * - subbytes
+ * - shiftrows
+ * - mixcolums\n
+ *
+ * is executed 9 times, after this addroundkey to finish the 9th\n
+ * round, after that the 10th round without mixcolums\n
+ * no further subfunctions to save cycles for function calls\n
+ * no structuring with "for (....)" to save cycles.\n
+ * \param[in] expanded_key expanded AES128 key
+ * \param[in/out] state 16 bytes of plain text and cipher text
+ * \return none
*/
void aes_encr(uint8_t *state, uint8_t *expanded_key);
/**
- * \brief
- * \param
- * \return
+ * \brief internal implementation of AES128 decryption.
+ * straightforward aes decryption implementation\n
+ * the order of substeps is the exact reverse of decryption\n
+ * inverse functions:
+ * - addRoundKey is its own inverse
+ * - rsbox is inverse of sbox
+ * - rightshift instead of leftshift
+ * - invMixColumns = barreto + mixColumns\n
+ *
+ * no further subfunctions to save cycles for function calls\n
+ * no structuring with "for (....)" to save cycles\n
+ * \param[in] expanded_key expanded AES128 key
+ * \param[in\out] state 16 bytes of cipher text and plain text
+ * \return none
*/
void aes_decr(uint8_t *state, uint8_t *expanded_key);
/**
- * \brief
- * \param
- * \return
+ * \brief AES128 encryption.
+ * Given AES128 key and 16 bytes plain text, cipher text of 16 bytes is computed.\n
+ * The AES implementation is in mode ECB (Electronic Code Book).\n
+ * \param[in] key AES128 key of size 16 bytes
+ * \param[in\out] state 16 bytes of plain text and cipher text
+ * \return none
*/
void aes_encrypt(uint8_t *state, uint8_t *key);
/**
- * \brief
- * \param
- * \return
+ * \brief AES128 decryption.
+ * Given AES128 key and 16 bytes cipher text, plain text of 16 bytes is computed.\n
+ * The AES implementation is in mode ECB (Electronic Code Book).\n
+ * \param[in] key AES128 key of size 16 bytes
+ * \param[in\out] state 16 bytes of cipher text and plain text
+ * \return none
*/
void aes_decrypt(uint8_t *state, uint8_t *key);
/**
- * \brief
- * \param
- * \return
+ * \brief Read the AES128 key from fileID #12 in EEPROM.
+ * \param[out] key AES128 key of size 16 bytes
+ * \return 0 on success, error otherwise.
*/
int32_t aes_read_key(uint8_t *key);
/**
- * \brief
- * \param
- * \return
+ * \brief Write the AES128 key to fileID #12 in EEPROM.
+ * \param[out] key AES128 key of size 16 bytes
+ * \return on success 0, error otherwise.
*/
int32_t aes_write_key(uint8_t *key);
private:
@@ -559,124 +685,374 @@
class cc3000_socket {
public:
/**
- * \brief
- * \param
- * \return
+ * \brief Ctor
+ * \param simplelink Reference to simple link object.
+ * \param hci Reference to hci object.
+ * \param event Reference to event object.
+ * \return none
*/
cc3000_socket(cc3000_simple_link &simplelink, cc3000_hci &hci, cc3000_event &event);
/**
- * \brief
+ * \brief Dtor
* \param
- * \return
+ * \return none
*/
~cc3000_socket();
/**
- * \brief
- * \param
- * \return
+ * \brief create an endpoint for communication.
+ * The socket function creates a socket that is bound to a specific transport service provider.\n
+ * This function is called by the application layer to obtain a socket handle.\n
+ *
+ * \param domain selects the protocol family which will be used for\n
+ * communication. On this version only AF_INET is supported\n
+ * \param type specifies the communication semantics. On this version\n
+ * only SOCK_STREAM, SOCK_DGRAM, SOCK_RAW are supported\n
+ * \param protocol specifies a particular protocol to be used with the\n
+ * socket IPPROTO_TCP, IPPROTO_UDP or IPPROTO_RAW are supported.\n
+ * \return On success, socket handle that is used for consequent socket operations\n
+ * On error, -1 is returned.\n
*/
int32_t socket(int32_t domain, int32_t type, int32_t protocol);
/**
- * \brief
- * \param
- * \return
+ * \brief accept a connection on a socket.
+ * This function is used with connection-based socket types\n
+ * (SOCK_STREAM). It extracts the first connection request on the\n
+ * queue of pending connections, creates a new connected socket, and\n
+ * returns a new file descriptor referring to that socket.\n
+ * The newly created socket is not in the listening state.\n
+ * The original socket sd is unaffected by this call.\n
+ * The argument sd is a socket that has been created with socket(),\n
+ * bound to a local address with bind(), and is listening for \n
+ * connections after a listen(). The argument addr is a pointer \n
+ * to a sockaddr structure. This structure is filled in with the \n
+ * address of the peer socket, as known to the communications layer.\n
+ * The exact format of the address returned addr is determined by the \n
+ * socket's address family. The addrlen argument is a value-result\n
+ * argument: it should initially contain the size of the structure\n
+ * pointed to by addr, on return it will contain the actual\n
+ * length (in bytes) of the address returned.\n
+ *
+ * \param[in] sd socket descriptor (handle)\n
+ * \param[out] addr the argument addr is a pointer to a sockaddr structure\n
+ * This structure is filled in with the address of the \n
+ * peer socket, as known to the communications layer. \n
+ * determined. The exact format of the address returned \n
+ * addr is by the socket's address sockaddr. \n
+ * On this version only AF_INET is supported.\n
+ * This argument returns in network order.\n
+ * \param[out] addrlen the addrlen argument is a value-result argument: \n
+ * it should initially contain the size of the structure\n
+ * pointed to by addr.\n
+ * \return For socket in blocking mode:\n
+ * - On success, socket handle. on failure negative\n
+ * For socket in non-blocking mode:\n
+ * - On connection establishment, socket handle\n
+ * - On connection pending, SOC_IN_PROGRESS (-2)\n
+ * - On failure, SOC_ERROR (-1)\n
+ * \sa socket ; bind ; listen
*/
int32_t accept(int32_t sd, sockaddr *addr, socklen_t *addrlen);
/**
- * \brief
- * \param
- * \return
+ * \brief assign a name to a socket.
+ * This function gives the socket the local address addr.\n
+ * addr is addrlen bytes long. Traditionally, this is called when a \n
+ * socket is created with socket, it exists in a name space (address \n
+ * family) but has no name assigned.\n
+ * It is necessary to assign a local address before a SOCK_STREAM\n
+ * socket may receive connections.\n
+ *
+ * \param[in] sd socket descriptor (handle)
+ * \param[out] addr specifies the destination address. On this version\n
+ * only AF_INET is supported.\n
+ * \param[out] addrlen contains the size of the structure pointed to by addr.\n
+ * \return On success, zero is returned.\n
+ * On error, -1 is returned.\n
+ * \sa socket ; accept ; listen
*/
int32_t bind(int32_t sd, const sockaddr *addr, int32_t addrlen);
/**
- * \brief
- * \param
- * \return
+ * \brief HostFlowControlConsumeBuff.
+ * if SEND_NON_BLOCKING is not defined - block until a free buffer is available,\n
+ * otherwise return the status of the available buffers.\n
+ *
+ * \param sd socket descriptor
+ * \return 0 in case there are buffers available, \n
+ * -1 in case of bad socket\n
+ * -2 if there are no free buffers present (only when SEND_NON_BLOCKING is enabled)\n
*/
int32_t HostFlowControlConsumeBuff(int32_t sd);
/**
- * \brief
- * \param
- * \return
+ * \brief The socket function closes a created socket.
+ * \param sd socket handle.
+ * \return On success, zero is returned. On error, -1 is returned.
*/
int32_t closesocket(int32_t sd);
/**
- * \brief
- * \param
- * \return
+ * \brief listen for connections on a socket.
+ * The willingness to accept incoming connections and a queue\n
+ * limit for incoming connections are specified with listen(),\n
+ * and then the connections are accepted with accept.\n
+ * The listen() call applies only to sockets of type SOCK_STREAM\n
+ * The backlog parameter defines the maximum length the queue of\n
+ * pending connections may grow to. \n
+ *
+ * \param[in] sd socket descriptor (handle)
+ * \param[in] backlog specifies the listen queue depth. On this version\n
+ * backlog is not supported.\n
+ * \return On success, zero is returned.\n
+ * On error, -1 is returned.\n
+ * \sa socket ; accept ; bind
+ * \note On this version, backlog is not supported
*/
int32_t listen(int32_t sd, int32_t backlog);
/**
- * \brief
- * \param
- * \return
+ * \brief initiate a connection on a socket.
+ * Function connects the socket referred to by the socket descriptor\n
+ * sd, to the address specified by addr. The addrlen argument \n
+ * specifies the size of addr. The format of the address in addr is \n
+ * determined by the address space of the socket. If it is of type \n
+ * SOCK_DGRAM, this call specifies the peer with which the socket is \n
+ * to be associated; this address is that to which datagrams are to be\n
+ * sent, and the only address from which datagrams are to be received. \n
+ * If the socket is of type SOCK_STREAM, this call attempts to make a \n
+ * connection to another socket. The other socket is specified by \n
+ * address, which is an address in the communications space of the\n
+ * socket. Note that the function implements only blocking behavior \n
+ * thus the caller will be waiting either for the connection \n
+ * establishment or for the connection establishment failure.\n
+ *
+ * \param[in] sd socket descriptor (handle)
+ * \param[in] addr specifies the destination addr. On this version\n
+ * only AF_INET is supported.\n
+ * \param[out] addrlen contains the size of the structure pointed to by addr
+ * \return On success, zero is returned.\n
+ On error, -1 is returned\n
+ * \sa socket
*/
int32_t connect(int32_t sd, const sockaddr *addr, int32_t addrlen);
/**
- * \brief
- * \param
- * \return
+ * \brief Monitor socket activity.
+ * Select allow a program to monitor multiple file descriptors,\n
+ * waiting until one or more of the file descriptors become \n
+ * "ready" for some class of I/O operation \n
+ *
+ * \param[in] nfds the highest-numbered file descriptor in any of the\n
+ * three sets, plus 1. \n
+ * \param[out] readsds socket descriptors list for read monitoring\n
+ * \param[out] writesds socket descriptors list for write monitoring\n
+ * \param[out] exceptsds socket descriptors list for exception monitoring\n
+ * \param[in] timeout is an upper bound on the amount of time elapsed\n
+ * before select() returns. Null means infinity \n
+ * timeout. The minimum timeout is 5 milliseconds,\n
+ * less than 5 milliseconds will be set\n
+ * automatically to 5 milliseconds.\n
+ * \return On success, select() returns the number of file descriptors\n
+ * contained in the three returned descriptor sets (that is, the\n
+ * total number of bits that are set in readfds, writefds,\n
+ * exceptfds) which may be zero if the timeout expires before\n
+ * anything interesting happens.\n
+ * On error, -1 is returned.\n
+ * *readsds - return the sockets on which Read request will\n
+ * return without delay with valid data.\n
+ * *writesds - return the sockets on which Write request \n
+ * will return without delay.\n
+ * *exceptsds - return the sockets which closed recently.\n
+ * \Note If the timeout value set to less than 5ms it will automatically\n
+ * change to 5ms to prevent overload of the system\n
+ * \sa socket
*/
int32_t select(int32_t nfds, fd_set *readsds, fd_set *writesds, fd_set *exceptsds, struct timeval *timeout);
/**
- * \brief
- * \param
- * \return
+ * \brief get socket options.
+ * This function manipulate the options associated with a socket.\n
+ * Options may exist at multiple protocol levels; they are always\n
+ * present at the uppermost socket level.\n
+ * When manipulating socket options the level at which the option \n
+ * resides and the name of the option must be specified. \n
+ * To manipulate options at the socket level, level is specified as \n
+ * SOL_SOCKET. To manipulate options at any other level the protocol \n
+ * number of the appropriate protocol controlling the option is \n
+ * supplied. For example, to indicate that an option is to be \n
+ * interpreted by the TCP protocol, level should be set to the \n
+ * protocol number of TCP; \n
+ * The parameters optval and optlen are used to access optval -\n
+ * use for setsockopt(). For getsockopt() they identify a buffer\n
+ * in which the value for the requested option(s) are to \n
+ * be returned. For getsockopt(), optlen is a value-result \n
+ * parameter, initially containing the size of the buffer \n
+ * pointed to by option_value, and modified on return to \n
+ * indicate the actual size of the value returned. If no option \n
+ * value is to be supplied or returned, option_value may be NULL.\n
+ *
+ * \param[in] sd socket handle
+ * \param[in] level defines the protocol level for this option
+ * \param[in] optname defines the option name to Interrogate
+ * \param[out] optval specifies a value for the option
+ * \param[out] optlen specifies the length of the option value
+ * \return On success, zero is returned. On error, -1 is returned
+ *
+ * \Note On this version the following two socket options are enabled:\n
+ * The only protocol level supported in this version is SOL_SOCKET (level).\n
+ * 1. SOCKOPT_RECV_TIMEOUT (optname)\n
+ * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout in milliseconds.\n
+ * In that case optval should be pointer to unsigned long.\n
+ * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on or off.\n
+ * In that case optval should be SOCK_ON or SOCK_OFF (optval).\n
+ * \sa setsockopt
*/
int32_t getsockopt (int32_t sd, int32_t level, int32_t optname, void *optval, socklen_t *optlen);
/**
- * \brief
- * \param
- * \return
+ * \brief Read data from socket (simple_link_recv).
+ * Return the length of the message on successful completion.\n
+ * If a message is too long to fit in the supplied buffer, excess bytes may\n
+ * be discarded depending on the type of socket the message is received from.\n
+ *
+ * \param sd socket handle
+ * \param buf read buffer
+ * \param len buffer length
+ * \param flags indicates blocking or non-blocking operation
+ * \param from pointer to an address structure indicating source address
+ * \param fromlen source address structure size
+ * \return Return the number of bytes received, or -1 if an error occurred
*/
int32_t simple_link_recv(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen, int32_t opcode);
/**
- * \brief
- * \param
- * \return
+ * \brief Transmit a message to another socket (simple_link_send).
+ * \param sd socket handle
+ * \param buf write buffer
+ * \param len buffer length
+ * \param flags On this version, this parameter is not supported
+ * \param to pointer to an address structure indicating destination address
+ * \param tolen destination address structure size
+ * \return Return the number of bytes transmitted, or -1 if an error\n
+ * occurred, or -2 in case there are no free buffers available\n
+ * (only when SEND_NON_BLOCKING is enabled)\n
*/
int32_t simple_link_send(int32_t sd, const void *buf, int32_t len, int32_t flags, const sockaddr *to, int32_t tolen, int32_t opcode);
/**
- * \brief
- * \param
- * \return
+ * \brief Receive a message from a connection-mode socket.
+ * \param[in] sd socket handle
+ * \param[out] buf Points to the buffer where the message should be stored
+ * \param[in] len Specifies the length in bytes of the buffer pointed to \n
+ * by the buffer argument.\n
+ * \param[in] flags Specifies the type of message reception. \n
+ * On this version, this parameter is not supported.\n
+ * \return Return the number of bytes received, or -1 if an error occurred
+ * \sa recvfrom
+ * \Note On this version, only blocking mode is supported.
*/
int32_t recv(int32_t sd, void *buf, int32_t len, int32_t flags);
/**
- * \brief
- * \param
- * \return
+ * \brief read data from socket (recvfrom).
+ * Receives a message from a connection-mode or connectionless-mode socket.\n
+ * Note that raw sockets are not supported.\n
+ *
+ * \param[in] sd socket handle
+ * \param[out] buf Points to the buffer where the message should be stored
+ * \param[in] len Specifies the length in bytes of the buffer pointed to \n
+ * by the buffer argument.\n
+ * \param[in] flags Specifies the type of message reception.\n
+ * On this version, this parameter is not supported.\n
+ * \param[in] from pointer to an address structure indicating the source\n
+ * address: sockaddr. On this version only AF_INET is\n
+ * supported.\n
+ * \param[in] fromlen source address structure size
+ * \return Return the number of bytes received, or -1 if an error occurred
+ * \sa recv
+ * \Note On this version, only blocking mode is supported.
*/
int32_t recvfrom(int32_t sd, void *buf, int32_t len, int32_t flags, sockaddr *from, socklen_t *fromlen);
/**
- * \brief
- * \param
- * \return
+ * \brief Transmit a message to another socket (send).
+ * \param sd socket handle
+ * \param buf Points to a buffer containing the message to be sent
+ * \param len message size in bytes
+ * \param flags On this version, this parameter is not supported
+ * \return Return the number of bytes transmitted, or -1 if an\n
+ * error occurred\n
+ * \Note On this version, only blocking mode is supported.
+ * \sa sendto
*/
int32_t send(int32_t sd, const void *buf, int32_t len, int32_t flags);
/**
- * \brief
- * \param
- * \return
+ * \brief Transmit a message to another socket (sendto).
+ * \param sd socket handle
+ * \param buf Points to a buffer containing the message to be sent
+ * \param len message size in bytes
+ * \param flags On this version, this parameter is not supported
+ * \param to pointer to an address structure indicating the destination\n
+ * address: sockaddr. On this version only AF_INET is\n
+ * supported.\n
+ * \param tolen destination address structure size
+ * \return Return the number of bytes transmitted, or -1 if an error occurred
+ * \Note On this version, only blocking mode is supported.
+ * \sa send
*/
int32_t sendto(int32_t sd, const void *buf, int32_t len, int32_t flags, const sockaddr *to, socklen_t tolen);
/**
- * \brief
- * \param
- * \return
+ * \brief Set CC3000 in mDNS advertiser mode in order to advertise itself.
+ * \param[in] mdns_enabled flag to enable/disable the mDNS feature
+ * \param[in] device_service_name Service name as part of the published\n
+ * canonical domain name\n
+ * \param[in] device_service_name_length Length of the service name
+ * \return On success, zero is returned,\n
+ * return SOC_ERROR if socket was not opened successfully, or if an error occurred.\n
*/
int32_t mdns_advertiser(uint16_t mdns_enabled, uint8_t * device_service_name, uint16_t device_service_name_length);
#ifndef CC3000_TINY_DRIVER
/**
- * \brief
- * \param
- * \return
+ * \brief Get host IP by name.\n
+ * Obtain the IP Address of machine on network\n
+ *
+ * \param[in] hostname host name
+ * \param[in] name_length name length
+ * \param[out] out_ip_addr This parameter is filled in with host IP address.\n
+ * In case that host name is not resolved, \n
+ * out_ip_addr is zero.\n
+ * \return On success, positive is returned.\n
+ * On error, negative is returned by its name.\n
+ * \note On this version, only blocking mode is supported. Also note that\n
+ * The function requires DNS server to be configured prior to its usage.\n
*/
int32_t gethostbyname(uint8_t *hostname, uint16_t name_length, uint32_t *out_ip_addr);
/**
- * \brief
- * \param
- * \return
+ * \brief set socket options.
+ * This function manipulate the options associated with a socket.\n
+ * Options may exist at multiple protocol levels; they are always\n
+ * present at the uppermost socket level.\n
+ * When manipulating socket options the level at which the option \n
+ * resides and the name of the option must be specified.\n
+ * To manipulate options at the socket level, level is specified as\n
+ * SOL_SOCKET. To manipulate options at any other level the protocol \n
+ * number of the appropriate protocol controlling the option is \n
+ * supplied. For example, to indicate that an option is to be \n
+ * interpreted by the TCP protocol, level should be set to the \n
+ * protocol number of TCP; \n
+ * The parameters optval and optlen are used to access optval - \n
+ * use for setsockopt(). For getsockopt() they identify a buffer\n
+ * in which the value for the requested option(s) are to \n
+ * be returned. For getsockopt(), optlen is a value-result \n
+ * parameter, initially containing the size of the buffer \n
+ * pointed to by option_value, and modified on return to \n
+ * indicate the actual size of the value returned. If no option \n
+ * value is to be supplied or returned, option_value may be NULL.\n
+ *
+ * \param[in] sd socket handle
+ * \param[in] level defines the protocol level for this option
+ * \param[in] optname defines the option name to Interrogate
+ * \param[in] optval specifies a value for the option
+ * \param[in] optlen specifies the length of the option value
+ * \return On success, zero is returned.\n
+ * On error, -1 is returned\n
+ *
+ * \Note On this version the following two socket options are enabled:\n
+ * The only protocol level supported in this version is SOL_SOCKET (level).\n
+ * 1. SOCKOPT_RECV_TIMEOUT (optname)\n
+ * SOCKOPT_RECV_TIMEOUT configures recv and recvfrom timeout in milliseconds.\n
+ * In that case optval should be pointer to unsigned long.\n
+ * 2. SOCKOPT_NONBLOCK (optname). sets the socket non-blocking mode on or off.\n
+ * In that case optval should be SOCK_ON or SOCK_OFF (optval).\n
+ * \sa getsockopt
*/
int32_t setsockopt(int32_t sd, int32_t level, int32_t optname, const void *optval, socklen_t optlen);
#endif
@@ -692,7 +1068,13 @@
public:
/**
* \brief Ctor
- * \param none
+ * \param irq IRQ pin
+ * \param cc3000_en Enable pin
+ * \param cc3000_cs Chip select pin
+ * \param cc3000_spi SPI object
+ * \param irq_port Port for IRQ pin (needed for enable/disable interrupts)
+ * \param event Reference to the event object.
+ * \param simple_link Reference to the simple link object.
* \return none
*/
cc3000_spi(PinName cc3000_irq, PinName cc3000_en, PinName cc3000_cs, SPI cc3000_spi, IRQn_Type irq_port, cc3000_event &event, cc3000_simple_link &simple_link);
@@ -708,77 +1090,81 @@
* \return none
*/
void close();
- /**
- * \param none
- * \return none
+ /**
+ * \brief Open the SPI interface
+ * \param none
+ * \return none
*/
void open();
- /**
- * \param buffer
- * \param length
- * \return none
+ /**
+ * \brief First SPI write after powerup (delay needed between SPI header and body)
+ * \param buffer pointer to write buffer
+ * \param length buffer length
+ * \return 0
*/
uint32_t first_write(uint8_t *buffer, uint16_t length);
- /**
- * \brief
- * \param
- * \return
+ /**
+ * \brief SPI Write function
+ * \param buffer pointer to write buffer
+ * \param length buffer length
+ * \return 0
*/
uint32_t write(uint8_t *buffer, uint16_t length);
- /**
- * \brief
- * \param
- * \return
+ /**
+ * \brief Low level SPI write
+ * \param data pointer to data buffer
+ * \param size number of bytes
+ * \return none
*/
void write_synchronous(uint8_t *data, uint16_t size);
- /**
- * \brief
- * \param
- * \return
+ /**
+ * \brief Low level SPI read
+ * \param data pointer to data buffer
+ * \param size number of bytes
+ * \return none
*/
void read_synchronous(uint8_t *data, uint16_t size);
- /**
- * \brief
- * \param
- * \return
+ /**
+ * \brief Process the received SPI Header and in accordance with it - continue reading the packet
+ * \param None
+ * \return 0
*/
uint32_t read_data_cont();
/**
- * \brief
- * \param
- * \return
+ * \brief Enable WLAN interrutp
+ * \param None
+ * \return None
*/
void wlan_irq_enable();
- /**
- * \brief
- * \param
- * \return
+ /**
+ * \brief Disable WLAN interrutp
+ * \param None
+ * \return None
*/
void wlan_irq_disable();
/**
- * \brief
- * \param
- * \return
- */
- void wlan_irq_set(uint8_t value);
- /**
- * \brief
- * \param
- * \return
+ * \brief Get WLAN interrupt status
+ * \param None
+ * \return 0 : No interrupt occured
+ * 1 : Interrupt occured
*/
uint32_t wlan_irq_read();
/**
- * \brief
- * \param
- * \return
+ * \brief SPI interrupt Handler.
+ * The external WLAN device asserts the IRQ line when data is ready.\n
+ * The host CPU needs to acknowledges the IRQ by asserting CS.\n
+ *
+ * \param none
+ * \return none
*/
void WLAN_IRQHandler();
/**
- * \brief
- * \param
- * \return
+ * \brief Enable/Disable the WLAN module
+ * \param value 1 : Enable
+ * 0 : Disable
+ * \return None
*/
- void write_wlan_en(uint8_t value);
+ void set_wlan_en(uint8_t value);
private:
tSpiInfo _spi_info;
InterruptIn _wlan_irq;
@@ -797,7 +1183,7 @@
public:
/**
* \brief Ctor
- * \param spi Reference to spi object.
+ * \param spi Reference to the spi object.
* \return none
*/
cc3000_hci(cc3000_spi &spi);
@@ -812,7 +1198,7 @@
* \param op_code command operation code
* \param buffer pointer to the command's arguments buffer
* \param length length of the arguments
- * \return ???
+ * \return 0
*/
uint16_t command_send(uint16_t op_code, uint8_t *buffer, uint8_t length);
/**
@@ -823,7 +1209,7 @@
* \param data_length length od data
* \param tail pointer to the data buffer
* \param tail_length buffer length
- * \return ???
+ * \return ESUCCESS
*/
uint32_t data_send(uint8_t op_code, uint8_t *args, uint16_t arg_length,
uint16_t data_length, const uint8_t *tail, uint16_t tail_length);
@@ -856,9 +1242,9 @@
public:
/**
* \brief Ctor
- * \param hci Reference to hci object.
- * \param event Reference to event object.
- * \param simple_link Reference to simple link object.
+ * \param hci Reference to the hci object.
+ * \param event Reference to the event object.
+ * \param simple_link Reference to the simple link object.
* \return none
*/
cc3000_nvmem(cc3000_hci &hci, cc3000_event &event, cc3000_simple_link &simple_link);
@@ -944,10 +1330,10 @@
public:
/**
* \brief Ctor
- * \param simple_link Reference to simple link object.
- * \param event Reference to event object.
- * \param spi Reference to spi object.
- * \param hci Reference to hci object.
+ * \param simple_link Reference to the simple link object.
+ * \param event Reference to the event object.
+ * \param spi Reference to the spi object.
+ * \param hci Reference to the hci object.
* \return none
*/
cc3000_wlan(cc3000_simple_link &simple_link, cc3000_event &event, cc3000_spi &spi, cc3000_hci &hci);
