Exemple #1
0
INT32 netapp_timeout_values(UINT32 *aucDHCP, UINT32 *aucARP,UINT32 *aucKeepalive,	UINT32 *aucInactivity)
{
    INT8 scRet;
    UINT8 *ptr;
    UINT8 *args;

    scRet = EFAIL;
    ptr = tSLInformation.pucTxCommandBuffer;
    args = (ptr + HEADERS_SIZE_CMD);

    // Set minimal values of timers
    MIN_TIMER_SET(*aucDHCP)
    MIN_TIMER_SET(*aucARP)
    MIN_TIMER_SET(*aucKeepalive)
    MIN_TIMER_SET(*aucInactivity)

    // Fill in temporary command buffer
    args = UINT32_TO_STREAM(args, *aucDHCP);
    args = UINT32_TO_STREAM(args, *aucARP);
    args = UINT32_TO_STREAM(args, *aucKeepalive);
    args = UINT32_TO_STREAM(args, *aucInactivity);

    // Initiate a HCI command
    hci_command_send(HCI_NETAPP_SET_TIMERS, ptr, NETAPP_SET_TIMER_PARAMS_LEN);

    // Wait for command complete event
    SimpleLinkWaitEvent(HCI_NETAPP_SET_TIMERS, &scRet);

    return(scRet);
}
Exemple #2
0
//*****************************************************************************
//
//!  netapp_timeout_values
//!
//!  @param  aucDHCP    DHCP lease time request, also impact
//!                     the DHCP renew timeout. Range: [0-0xffffffff] seconds,
//!                     0 or 0xffffffff == infinity lease timeout.
//!                     Resolution:10 seconds. Influence: only after
//!                     reconnecting to the AP.
//!                     Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds.
//!                     The parameter is saved into the CC3000 NVMEM.
//!                     The default value on CC3000 is 14400 seconds.
//!
//!  @param  aucARP     ARP refresh timeout, if ARP entry is not updated by
//!                     incoming packet, the ARP entry will be  deleted by
//!                     the end of the timeout.
//!                     Range: [0-0xffffffff] seconds, 0 == infinity ARP timeout
//!                     Resolution: 10 seconds. Influence: on runtime.
//!                     Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds
//!                     The parameter is saved into the CC3000 NVMEM.
//!                     The default value on CC3000 is 3600 seconds.
//!
//!  @param  aucKeepalive   Keepalive event sent by the end of keepalive timeout
//!                         Range: [0-0xffffffff] seconds, 0 == infinity timeout
//!                         Resolution: 10 seconds.
//!                         Influence: on runtime.
//!                         Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec
//!                         The parameter is saved into the CC3000 NVMEM.
//!                         The default value on CC3000 is 10 seconds.
//!
//!  @param  aucInactivity   Socket inactivity timeout, socket timeout is
//!                          refreshed by incoming or outgoing packet, by the
//!                          end of the socket timeout the socket will be closed
//!                          Range: [0-0xffffffff] sec, 0 == infinity timeout.
//!                          Resolution: 10 seconds. Influence: on runtime.
//!                          Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec
//!                          The parameter is saved into the CC3000 NVMEM.
//!                          The default value on CC3000 is 60 seconds.
//!
//!  @return       return on success 0, otherwise error.
//!
//!  @brief       Set new timeout values. Function set new timeout values for:
//!               DHCP lease timeout, ARP  refresh timeout, keepalive event
//!               timeout and socket inactivity timeout
//!
//! @note         If a parameter set to non zero value which is less than 20s,
//!               it will be set automatically to 20s.
//!
//*****************************************************************************
long c_netapp_timeout_values(
    uint32_t *aucDHCP,
    uint32_t *aucARP,
    uint32_t *aucKeepalive,
    uint32_t *aucInactivity)
{
    signed char scRet;
    uint8_t *args;

    scRet = EFAIL;
    args = hci_get_cmd_buffer();

    // Set minimal values of timers
    MIN_TIMER_SET(*aucDHCP)
    MIN_TIMER_SET(*aucARP)
    MIN_TIMER_SET(*aucKeepalive)
    MIN_TIMER_SET(*aucInactivity)

    // Fill in temporary command buffer
    args = UINT32_TO_STREAM(args, *aucDHCP);
    args = UINT32_TO_STREAM(args, *aucARP);
    args = UINT32_TO_STREAM(args, *aucKeepalive);
    args = UINT32_TO_STREAM(args, *aucInactivity);

    // Initiate a HCI command
    hci_command_send(HCI_NETAPP_SET_TIMERS, NETAPP_SET_TIMER_PARAMS_LEN,
        HCI_NETAPP_SET_TIMERS, &scRet);

    return(scRet);
}
Exemple #3
0
/*****************************************************************************
*
*  netapp.c  - CC3000 Host Driver Implementation.
*  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
*
*  Redistribution and use in source and binary forms, with or without
*  modification, are permitted provided that the following conditions
*  are met:
*
*    Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
*
*    Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the
*    distribution.
*
*    Neither the name of Texas Instruments Incorporated nor the names of
*    its contributors may be used to endorse or promote products derived
*    from this software without specific prior written permission.
*
*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
*  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
*  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
*  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
*  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
*  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
*  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
*  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*****************************************************************************/
#include <string.h>
#include "netapp.h"
#include "hci.h"
#include "socket.h"
#include "evnt_handler.h"
#include "nvmem.h"

#define MIN_TIMER_VAL_SECONDS      20
#define MIN_TIMER_SET(t)    if ((0 != t) && (t < MIN_TIMER_VAL_SECONDS)) \
                            { \
                                t = MIN_TIMER_VAL_SECONDS; \
                            }


#define NETAPP_DHCP_PARAMS_LEN              (20)
#define NETAPP_SET_TIMER_PARAMS_LEN         (20)
#define NETAPP_SET_DEBUG_LEVEL_PARAMS_LEN   (4)
#define NETAPP_PING_SEND_PARAMS_LEN         (16)

#ifndef __ENABLE_MULTITHREADED_SUPPORT__
#define c_nvmem_set_mac_address nvmem_set_mac_address
#endif /* __ENABLE_MULTITHREADED_SUPPORT__ */


//*****************************************************************************
//
//!  netapp_config_mac_adrress
//!
//!  @param  mac   device mac address, 6 bytes. Saved: yes
//!
//!  @return       return on success 0, otherwise error.
//!
//!  @brief        Configure device MAC address and store it in NVMEM.
//!                The value of the MAC address configured through the API will
//!                  be stored in CC3000 non volatile memory, thus preserved
//!                over resets.
//
//*****************************************************************************
#ifdef __ENABLE_MULTITHREADED_SUPPORT__
long  c_netapp_config_mac_adrress( unsigned char *mac )
#else /* __ENABLE_MULTITHREADED_SUPPORT__ */
long  netapp_config_mac_adrress( unsigned char *mac )
#endif /* __ENABLE_MULTITHREADED_SUPPORT__ */
{
   return  c_nvmem_set_mac_address(mac);
}

//*****************************************************************************
//
//!  netapp_dhcp
//!
//!  @param  aucIP               device mac address, 6 bytes. Saved: yes
//!  @param  aucSubnetMask       device mac address, 6 bytes. Saved: yes
//!  @param  aucDefaultGateway   device mac address, 6 bytes. Saved: yes
//!  @param  aucDNSServer        device mac address, 6 bytes. Saved: yes
//!
//!  @return       return on success 0, otherwise error.
//!
//!  @brief       netapp_dhcp is used to configure the network interface,
//!               static or dynamic (DHCP).\n In order to activate DHCP mode,
//!               aucIP, aucSubnetMask, aucDefaultGateway must be 0.
//!               The default mode of CC3000 is DHCP mode.
//!               Note that the configuration is saved in non volatile memory
//!               and thus preserved over resets.
//!
//! @note         If the mode is altered a reset of CC3000 device is required
//!               in order to apply changes.\nAlso note that asynchronous event
//!               of DHCP_EVENT, which is generated when an IP address is
//!               allocated either by the DHCP server or due to static
//!               allocation is generated only upon a connection to the
//!               AP was established.
//!
//*****************************************************************************
#ifdef __ENABLE_MULTITHREADED_SUPPORT__
long c_netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,
                           unsigned long *aucDefaultGateway, unsigned long *aucDNSServer)
#else /* __ENABLE_MULTITHREADED_SUPPORT__ */
long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,
                           unsigned long *aucDefaultGateway, unsigned long *aucDNSServer)
#endif /* __ENABLE_MULTITHREADED_SUPPORT__ */
{
    signed char scRet;
    unsigned char *ptr;
    unsigned char *args;

    scRet = EFAIL;
    ptr = tSLInformation.pucTxCommandBuffer;
    args = (ptr + HEADERS_SIZE_CMD);

    // Fill in temporary command buffer
    ARRAY_TO_STREAM(args,aucIP,4);
    ARRAY_TO_STREAM(args,aucSubnetMask,4);
    ARRAY_TO_STREAM(args,aucDefaultGateway,4);
    args = UINT32_TO_STREAM(args, 0);
    ARRAY_TO_STREAM(args,aucDNSServer,4);

    // Initiate a HCI command
    hci_command_send(HCI_NETAPP_DHCP, ptr, NETAPP_DHCP_PARAMS_LEN);

    // Wait for command complete event
    SimpleLinkWaitEvent(HCI_NETAPP_DHCP, &scRet);

    return(scRet);
}


//*****************************************************************************
//
//!  netapp_timeout_values
//!
//!  @param  aucDHCP    DHCP lease time request, also impact
//!                     the DHCP renew timeout. Range: [0-0xffffffff] seconds,
//!                     0 or 0xffffffff == infinity lease timeout.
//!                     Resolution:10 seconds. Influence: only after
//!                     reconnecting to the AP.
//!                     Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds.
//!                     The parameter is saved into the CC3000 NVMEM.
//!                     The default value on CC3000 is 14400 seconds.
//!
//!  @param  aucARP     ARP refresh timeout, if ARP entry is not updated by
//!                     incoming packet, the ARP entry will be  deleted by
//!                     the end of the timeout.
//!                     Range: [0-0xffffffff] seconds, 0 == infinity ARP timeout
//!                     Resolution: 10 seconds. Influence: on runtime.
//!                     Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds
//!                     The parameter is saved into the CC3000 NVMEM.
//!                     The default value on CC3000 is 3600 seconds.
//!
//!  @param  aucKeepalive   Keepalive event sent by the end of keepalive timeout
//!                         Range: [0-0xffffffff] seconds, 0 == infinity timeout
//!                         Resolution: 10 seconds.
//!                         Influence: on runtime.
//!                         Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec
//!                         The parameter is saved into the CC3000 NVMEM.
//!                         The default value on CC3000 is 10 seconds.
//!
//!  @param  aucInactivity   Socket inactivity timeout, socket timeout is
//!                          refreshed by incoming or outgoing packet, by the
//!                          end of the socket timeout the socket will be closed
//!                          Range: [0-0xffffffff] sec, 0 == infinity timeout.
//!                          Resolution: 10 seconds. Influence: on runtime.
//!                          Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec
//!                          The parameter is saved into the CC3000 NVMEM.
//!                          The default value on CC3000 is 60 seconds.
//!
//!  @return       return on success 0, otherwise error.
//!
//!  @brief       Set new timeout values. Function set new timeout values for:
//!               DHCP lease timeout, ARP  refresh timeout, keepalive event
//!               timeout and socket inactivity timeout
//!
//! @note         If a parameter set to non zero value which is less than 20s,
//!               it will be set automatically to 20s.
//!
//*****************************************************************************

#ifndef CC3000_TINY_DRIVER
#ifdef __ENABLE_MULTITHREADED_SUPPORT__
long c_netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP,
                        unsigned long *aucKeepalive, unsigned long *aucInactivity)
#else /* __ENABLE_MULTITHREADED_SUPPORT__ */
long netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP,
                        unsigned long *aucKeepalive, unsigned long *aucInactivity)
#endif /* __ENABLE_MULTITHREADED_SUPPORT__ */
{
    signed char scRet;
    unsigned char *ptr;
    unsigned char *args;

    scRet = EFAIL;
    ptr = tSLInformation.pucTxCommandBuffer;
    args = (ptr + HEADERS_SIZE_CMD);

    // Set minimal values of timers
    MIN_TIMER_SET(*aucDHCP)
    MIN_TIMER_SET(*aucARP)
    MIN_TIMER_SET(*aucKeepalive)
    MIN_TIMER_SET(*aucInactivity)

    // Fill in temporary command buffer
    args = UINT32_TO_STREAM(args, *aucDHCP);
    args = UINT32_TO_STREAM(args, *aucARP);
    args = UINT32_TO_STREAM(args, *aucKeepalive);
    args = UINT32_TO_STREAM(args, *aucInactivity);

    // Initiate a HCI command
    hci_command_send(HCI_NETAPP_SET_TIMERS, ptr, NETAPP_SET_TIMER_PARAMS_LEN);

    // Wait for command complete event
    SimpleLinkWaitEvent(HCI_NETAPP_SET_TIMERS, &scRet);

    return(scRet);
}
Exemple #4
0
//*****************************************************************************
//
//!  netapp_timeout_values
//!
//!  @param  aucDHCP    DHCP lease time request, also impact
//!                     the DHCP renew timeout. Range: [0-0xffffffff] seconds,
//!                     0 or 0xffffffff == infinity lease timeout.
//!                     Resolution:10 seconds. Influence: only after
//!                     reconnecting to the AP.
//!                     Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds.
//!                     The parameter is saved into the CC3000 NVMEM.
//!                     The default value on CC3000 is 14400 seconds.
//!
//!  @param  aucARP     ARP refresh timeout, if ARP entry is not updated by
//!                     incoming packet, the ARP entry will be  deleted by
//!                     the end of the timeout.
//!                     Range: [0-0xffffffff] seconds, 0 == infinity ARP timeout
//!                     Resolution: 10 seconds. Influence: on runtime.
//!                     Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 seconds
//!                     The parameter is saved into the CC3000 NVMEM.
//!	                    The default value on CC3000 is 3600 seconds.
//!
//!  @param  aucKeepalive   Keepalive event sent by the end of keepalive timeout
//!                         Range: [0-0xffffffff] seconds, 0 == infinity timeout
//!                         Resolution: 10 seconds.
//!                         Influence: on runtime.
//!                         Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec
//!                         The parameter is saved into the CC3000 NVMEM.
//!                         The default value on CC3000 is 10 seconds.
//!
//!  @param  aucInactivity   Socket inactivity timeout, socket timeout is
//!                          refreshed by incoming or outgoing packet, by the
//!                          end of the socket timeout the socket will be closed
//!                          Range: [0-0xffffffff] sec, 0 == infinity timeout.
//!                          Resolution: 10 seconds. Influence: on runtime.
//!                          Minimal bound value: MIN_TIMER_VAL_SECONDS - 20 sec
//!                          The parameter is saved into the CC3000 NVMEM.
//!	                         The default value on CC3000 is 60 seconds.
//!
//!  @return       none, but cc3000_get_return_uint32() should read 0 on sucess
//!
//!  @brief       Set new timeout values. Function set new timeout values for:
//!               DHCP lease timeout, ARP  refresh timeout, keepalive event
//!               timeout and socket inactivity timeout
//!
//! @note         If a parameter set to non zero value which is less than 20s,
//!               it will be set automatically to 20s.
//!
//*****************************************************************************
void netapp_timeout_values(uint32 aucDHCP, uint32 aucARP, uint32 aucKeepalive, uint32 aucInactivity){


	// Set minimal values of timers
	MIN_TIMER_SET(aucDHCP)
    MIN_TIMER_SET(aucARP)
	MIN_TIMER_SET(aucKeepalive)
	MIN_TIMER_SET(aucInactivity)

	cc3000_desired_state++;
	cc3000_hci_start_command(HCI_NETAPP_SET_TIMERS, 16);
	cc3000_hci_send_uint32(aucDHCP);
	cc3000_hci_send_uint32(aucARP);
	cc3000_hci_send_uint32(aucKeepalive);
	cc3000_hci_send_uint32(aucInactivity);
	cc3000_hci_end_command();
	cc3000_hci_expect(HCI_NETAPP_SET_TIMERS);
}
Exemple #5
0
long netapp_timeout_values(unsigned long *aucDHCP, unsigned long *aucARP,
                           unsigned long *aucKeepalive,
                           unsigned long *aucInactivity)
{
  int8_t scRet;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

  scRet = EFAIL;
  ptr = tSLInformation.pucTxCommandBuffer;
  args = (ptr + HEADERS_SIZE_CMD);

  /* Set minimal values of timers */

  MIN_TIMER_SET(*aucDHCP)
  MIN_TIMER_SET(*aucARP)
  MIN_TIMER_SET(*aucKeepalive)
  MIN_TIMER_SET(*aucInactivity)

  /* Fill in temporary command buffer */

  args = UINT32_TO_STREAM(args, *aucDHCP);
  args = UINT32_TO_STREAM(args, *aucARP);
  args = UINT32_TO_STREAM(args, *aucKeepalive);
  args = UINT32_TO_STREAM(args, *aucInactivity);

  /* Initiate a HCI command */

  hci_command_send(HCI_NETAPP_SET_TIMERS, ptr, NETAPP_SET_TIMER_PARAMS_LEN);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_NETAPP_SET_TIMERS, &scRet);

  cc3000_lib_unlock();

  return scRet;
}