示例#1
0
void wlan_start(uint16_t usPatchesAvailableAtHost)
{
  cc3000_lib_lock();

  tSLInformation.NumberOfSentPackets = 0;
  tSLInformation.NumberOfReleasedPackets = 0;
  tSLInformation.usRxEventOpcode = 0;
  tSLInformation.usNumberOfFreeBuffers = 0;
  tSLInformation.usSlBufferLength = 0;
  tSLInformation.usBufferSize = 0;
  tSLInformation.usRxDataPending = 0;
  tSLInformation.slTransmitDataError = 0;
  tSLInformation.usEventOrDataReceived = 0;
  tSLInformation.pucReceivedData = 0;

  /* Init spi */

  cc3000_open(SpiReceiveHandler);

  SimpleLink_Init_Start(usPatchesAvailableAtHost);

  /* Read Buffer's size and finish */

  hci_command_send(HCI_CMND_READ_BUFFER_SIZE, tSLInformation.pucTxCommandBuffer, 0);
  SimpleLinkWaitEvent(HCI_CMND_READ_BUFFER_SIZE, 0);
  cc3000_lib_unlock();
}
示例#2
0
long wlan_ioctl_get_scan_results(unsigned long ulScanTimeout, uint8_t *ucResults)
{
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

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

  /* Fill in temporary command buffer */

  args = UINT32_TO_STREAM(args, ulScanTimeout);

  /* Initiate a HCI command */

  hci_command_send(HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS,
                   ptr, WLAN_GET_SCAN_RESULTS_PARAMS_LEN);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_GET_SCAN_RESULTS, ucResults);

  cc3000_lib_unlock();

  return 0;
}
示例#3
0
long wlan_ioctl_del_profile(unsigned long ulIndex)
{
  long ret;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

  ptr = tSLInformation.pucTxCommandBuffer;
  args = (uint8_t *)(ptr + HEADERS_SIZE_CMD);

  /* Fill in HCI packet structure */

  args = UINT32_TO_STREAM(args, ulIndex);
  ret = EFAIL;

  /* Initiate a HCI command */

  hci_command_send(HCI_CMND_WLAN_IOCTL_DEL_PROFILE,
                   ptr, WLAN_DEL_PROFILE_PARAMS_LEN);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_DEL_PROFILE, &ret);

  cc3000_lib_unlock();

  return ret;
}
示例#4
0
long wlan_smart_config_start(unsigned long algoEncryptedFlag)
{
  long ret;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

  ret  = EFAIL;
  ptr  = tSLInformation.pucTxCommandBuffer;
  args = (uint8_t *)(ptr + HEADERS_SIZE_CMD);

  /* Fill in HCI packet structure */

  args = UINT32_TO_STREAM(args, algoEncryptedFlag);

  hci_command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START, ptr,
                   WLAN_SMART_CONFIG_START_PARAMS_LEN);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_START, &ret);

  cc3000_lib_unlock();
  return ret;
}
示例#5
0
long netapp_ping_send(unsigned long *ip, unsigned long ulPingAttempts,
                      unsigned long ulPingSize, unsigned long ulPingTimeout)
{
  int8_t scRet;
  uint8_t *ptr, *args;

  cc3000_lib_lock();

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

  /* Fill in temporary command buffer */

  args = UINT32_TO_STREAM(args, *ip);
  args = UINT32_TO_STREAM(args, ulPingAttempts);
  args = UINT32_TO_STREAM(args, ulPingSize);
  args = UINT32_TO_STREAM(args, ulPingTimeout);

  /* Initiate a HCI command */

  hci_command_send(HCI_NETAPP_PING_SEND, ptr, NETAPP_PING_SEND_PARAMS_LEN);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_NETAPP_PING_SEND, &scRet);

  cc3000_lib_unlock();

  return scRet;
}
示例#6
0
long netapp_dhcp(unsigned long *aucIP, unsigned long *aucSubnetMask,
                 unsigned long *aucDefaultGateway, unsigned long *aucDNSServer)
{
  int8_t scRet;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

  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);

  cc3000_lib_unlock();

  return(scRet);
}
示例#7
0
uint8_t nvmem_read_sp_version(uint8_t *patchVer)
{
  uint8_t *ptr;
  /* 1st byte is the status and the rest is the SP version */
  uint8_t  retBuf[5];

  cc3000_lib_lock();

  ptr = tSLInformation.pucTxCommandBuffer;

  /* Initiate a HCI command, no args are required */

  hci_command_send(HCI_CMND_READ_SP_VERSION, ptr, 0);
  SimpleLinkWaitEvent(HCI_CMND_READ_SP_VERSION, retBuf);

  /* Package ID */

  *patchVer = retBuf[3];

  /* Package build number */

  *(patchVer+1) = retBuf[4];

  cc3000_lib_unlock();

  return retBuf[0];
}
示例#8
0
signed long nvmem_create_entry(unsigned long ulFileId, unsigned long ulNewLen)
{
  uint8_t *ptr;
  uint8_t *args;
  uint16_t retval;

  cc3000_lib_lock();

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

  /*( Fill in HCI packet structure */

  args = UINT32_TO_STREAM(args, ulFileId);
  args = UINT32_TO_STREAM(args, ulNewLen);

  /* Initiate a HCI command */

  hci_command_send(HCI_CMND_NVMEM_CREATE_ENTRY,ptr, NVMEM_CREATE_PARAMS_LEN);

  SimpleLinkWaitEvent(HCI_CMND_NVMEM_CREATE_ENTRY, &retval);

  cc3000_lib_unlock();

  return retval;
}
示例#9
0
signed long nvmem_write(unsigned long ulFileId, unsigned long ulLength,
                        unsigned long ulEntryOffset, uint8_t *buff)
{
  long iRes;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

  iRes = EFAIL;

  ptr = tSLInformation.pucTxCommandBuffer;
  args = (ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE);

  /* Fill in HCI packet structure */

  args = UINT32_TO_STREAM(args, ulFileId);
  args = UINT32_TO_STREAM(args, 12);
  args = UINT32_TO_STREAM(args, ulLength);
  args = UINT32_TO_STREAM(args, ulEntryOffset);

  memcpy((ptr + SPI_HEADER_SIZE + HCI_DATA_CMD_HEADER_SIZE +
          NVMEM_WRITE_PARAMS_LEN),buff,ulLength);

  /* Initiate a HCI command but it will come on data channel */

  hci_data_command_send(HCI_CMND_NVMEM_WRITE, ptr, NVMEM_WRITE_PARAMS_LEN,
                        ulLength);

  SimpleLinkWaitEvent(HCI_EVNT_NVMEM_WRITE, &iRes);

  cc3000_lib_unlock();

  return iRes;
}
示例#10
0
long netapp_set_debug_level(unsigned long ulLevel)
{
  int8_t scRet;
  uint8_t *ptr, *args;

  cc3000_lib_lock();

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

  /* Fill in temporary command buffer */

  args = UINT32_TO_STREAM(args, ulLevel);

  /* Initiate a HCI command */

  hci_command_send(HCI_NETAPP_SET_DEBUG_LEVEL, ptr, NETAPP_SET_DEBUG_LEVEL_PARAMS_LEN);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_NETAPP_SET_DEBUG_LEVEL, &scRet);

  cc3000_lib_unlock();

  return scRet;
}
示例#11
0
long wlan_ioctl_set_connection_policy(unsigned long should_connect_to_open_ap,
                                      unsigned long ulShouldUseFastConnect,
                                      unsigned long ulUseProfiles)
{
  long ret;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

  ret = EFAIL;
  ptr = tSLInformation.pucTxCommandBuffer;
  args = (uint8_t *)(ptr + HEADERS_SIZE_CMD);

  /* Fill in HCI packet structure */

  args = UINT32_TO_STREAM(args, should_connect_to_open_ap);
  args = UINT32_TO_STREAM(args, ulShouldUseFastConnect);
  args = UINT32_TO_STREAM(args, ulUseProfiles);

  /* Initiate a HCI command */

  hci_command_send(HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY,
                   ptr, WLAN_SET_CONNECTION_POLICY_PARAMS_LEN);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SET_CONNECTION_POLICY, &ret);

  cc3000_lib_unlock();
  return ret;
}
示例#12
0
int cc3000_do_accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen)
{
  int ret;
  cc3000_lib_lock();
  ret = cc3000_accept_impl(sockfd, addr, addrlen);
  cc3000_lib_unlock();
  return ret;
}
示例#13
0
long wlan_connect(unsigned long ulSecType, FAR const char *ssid,
                  long ssid_len, FAR const uint8_t *bssid,
                  FAR const uint8_t *key, long key_len)
{
  long ret;
  uint8_t *ptr;
  uint8_t *args;
  uint8_t bssid_zero[] = {0, 0, 0, 0, 0, 0};

  cc3000_lib_lock();

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

  /* Fill in command buffer */

  args = UINT32_TO_STREAM(args, 0x0000001c);
  args = UINT32_TO_STREAM(args, ssid_len);
  args = UINT32_TO_STREAM(args, ulSecType);
  args = UINT32_TO_STREAM(args, 0x00000010 + ssid_len);
  args = UINT32_TO_STREAM(args, key_len);
  args = UINT16_TO_STREAM(args, 0);

  /* Padding shall be zeroed */

  if (bssid)
    {
      ARRAY_TO_STREAM(args, bssid, ETH_ALEN);
    }
  else
    {
      ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
    }

  ARRAY_TO_STREAM(args, ssid, ssid_len);

  if (key_len && key)
    {
      ARRAY_TO_STREAM(args, key, key_len);
    }

  /* Initiate a HCI command */

  hci_command_send(HCI_CMND_WLAN_CONNECT, ptr, WLAN_CONNECT_PARAM_LEN +
                   ssid_len + key_len - 1);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_CONNECT, &ret);
  set_errno(ret);
  cc3000_lib_unlock();
  return ret;
}
示例#14
0
int cc3000_closesocket(int sockfd)
{
  int ret;
  cc3000_lib_lock();
  ret = cc3000_closesocket_impl(sockfd);
#ifdef CONFIG_CC3000_MT
  cc3000_remove_socket(sockfd);
#endif
  cc3000_lib_unlock();
  return ret;
}
示例#15
0
int cc3000_socket(int domain, int type, int protocol)
{
  int sd;

  if (type < SOCK_STREAM || type >= ARRAY_SIZE(bsd2ti_types))
    {
      errno = EPROTOTYPE;
      return -1;
    }

  switch (domain)
    {
    case AF_INET:
      domain = CC3000_AF_INET;
      break;

    case AF_INET6:
      domain = CC3000_AF_INET6;
      break;

    default:
      errno = EAFNOSUPPORT;
      return -1;
    }

  switch (protocol)
    {
      case CC3000_IPPROTO_IP:
      case CC3000_IPPROTO_ICMP:
      case CC3000_IPPROTO_TCP:
      case CC3000_IPPROTO_UDP:
      case CC3000_IPPROTO_IPV6:
      case CC3000_IPPROTO_NONE:
      case CC3000_IPPROTO_TX_TEST_RAW:
      case CC3000_IPPROTO_RAW:
      case CC3000_IPPROTO_MAX:
        break;

      default:
        errno = EPROTONOSUPPORT;
        return -1;
    }

  cc3000_lib_lock();
  type = bsd2ti_types[type];
  sd = cc3000_socket_impl(domain, type, protocol);
#ifdef CONFIG_CC3000_MT
  cc3000_add_socket(sd);
#endif
  cc3000_lib_unlock();
  return sd;
}
示例#16
0
long wlan_set_event_mask(unsigned long ulMask)
{
  long ret;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

  if ((ulMask & HCI_EVNT_WLAN_TX_COMPLETE) == HCI_EVNT_WLAN_TX_COMPLETE)
    {
      tSLInformation.InformHostOnTxComplete = 0;

      /* Since an event is a virtual event - i.e. it is not coming from CC3000
       * there is no need to send anything to the device if it was an only event
       */

      if (ulMask == HCI_EVNT_WLAN_TX_COMPLETE)
        {
          return 0;
        }

      ulMask &= ~HCI_EVNT_WLAN_TX_COMPLETE;
      ulMask |= HCI_EVNT_WLAN_UNSOL_BASE;
    }
  else
    {
      tSLInformation.InformHostOnTxComplete = 1;
    }

  ret = EFAIL;
  ptr = tSLInformation.pucTxCommandBuffer;
  args = (uint8_t *)(ptr + HEADERS_SIZE_CMD);

  /* Fill in HCI packet structure */

  args = UINT32_TO_STREAM(args, ulMask);

  /* Initiate a HCI command */

  hci_command_send(HCI_CMND_EVENT_MASK,
                   ptr, WLAN_SET_MASK_PARAMS_LEN);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_EVENT_MASK, &ret);

  cc3000_lib_unlock();

  return ret;
}
示例#17
0
int cc3000_closesocket(int sockfd)
{
  int ret;

#ifdef CONFIG_CC3000_MT
  waitlldbg("remove\n");
  cc3000_remove_socket(sockfd);
#endif
  cc3000_lib_lock();
  waitlldbg("Call closesocketl\n");
  ret = cc3000_closesocket_impl(sockfd);
  waitlldbg("return closesocket\n");
  cc3000_lib_unlock();
  return ret;
}
示例#18
0
long wlan_ioctl_set_scan_params(unsigned long uiEnable,
                                unsigned long uiMinDwellTime,
                                unsigned long uiMaxDwellTime,
                                unsigned long uiNumOfProbeRequests,
                                unsigned long uiChannelMask,long iRSSIThreshold,
                                unsigned long uiSNRThreshold,
                                unsigned long uiDefaultTxPower,
                                unsigned long *aiIntervalList)
{
  unsigned long  uiRes;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

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

  /* Fill in temporary command buffer */

  args = UINT32_TO_STREAM(args, 36);
  args = UINT32_TO_STREAM(args, uiEnable);
  args = UINT32_TO_STREAM(args, uiMinDwellTime);
  args = UINT32_TO_STREAM(args, uiMaxDwellTime);
  args = UINT32_TO_STREAM(args, uiNumOfProbeRequests);
  args = UINT32_TO_STREAM(args, uiChannelMask);
  args = UINT32_TO_STREAM(args, iRSSIThreshold);
  args = UINT32_TO_STREAM(args, uiSNRThreshold);
  args = UINT32_TO_STREAM(args, uiDefaultTxPower);
  ARRAY_TO_STREAM(args, aiIntervalList, sizeof(unsigned long) *
                  SL_SET_SCAN_PARAMS_INTERVAL_LIST_SIZE);

  /* Initiate a HCI command */

  hci_command_send(HCI_CMND_WLAN_IOCTL_SET_SCANPARAM,
                   ptr, WLAN_SET_SCAN_PARAMS_LEN);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SET_SCANPARAM, &uiRes);

  cc3000_lib_unlock();

  return uiRes;
}
示例#19
0
void netapp_ipconfig(tNetappIpconfigRetArgs * ipconfig)
{
  uint8_t *ptr;

  cc3000_lib_lock();

  ptr = tSLInformation.pucTxCommandBuffer;

  /* Initiate a HCI command */

  hci_command_send(HCI_NETAPP_IPCONFIG, ptr, 0);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_NETAPP_IPCONFIG, ipconfig);

  cc3000_lib_unlock();
}
示例#20
0
void wlan_init(tWlanCB sWlanCB, tFWPatches sFWPatches,
               tDriverPatches sDriverPatches,
               tBootLoaderPatches sBootLoaderPatches)
{
  cc3000_lib_lock();
  tSLInformation.sFWPatches = sFWPatches;
  tSLInformation.sDriverPatches = sDriverPatches;
  tSLInformation.sBootLoaderPatches = sBootLoaderPatches;

  /* Init I/O callback */
  /* Init asynchronous events callback */

  tSLInformation.sWlanCB= sWlanCB;

  /* By default TX Complete events are routed to host too */

  tSLInformation.InformHostOnTxComplete = 1;
  cc3000_lib_unlock();
}
示例#21
0
long wlan_smart_config_stop(void)
{
  long ret;
  uint8_t *ptr;

  cc3000_lib_lock();

  ret = EFAIL;
  ptr = tSLInformation.pucTxCommandBuffer;

  hci_command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP, ptr, 0);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_STOP, &ret);

  cc3000_lib_unlock();
  return ret;
}
示例#22
0
void netapp_ping_report(void)
{
  uint8_t *ptr;
  ptr = tSLInformation.pucTxCommandBuffer;
  int8_t scRet;

  cc3000_lib_lock();

  scRet = EFAIL;

  /* Initiate a HCI command */

  hci_command_send(HCI_NETAPP_PING_REPORT, ptr, 0);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_NETAPP_PING_REPORT, &scRet);

  cc3000_lib_unlock();
}
示例#23
0
long wlan_connect(char *ssid, long ssid_len)
{
  long ret;
  uint8_t *ptr;
  uint8_t *args;
  uint8_t bssid_zero[] = {0, 0, 0, 0, 0, 0};

  cc3000_lib_lock();

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

  /* Fill in command buffer */

  args = UINT32_TO_STREAM(args, 0x0000001c);
  args = UINT32_TO_STREAM(args, ssid_len);
  args = UINT32_TO_STREAM(args, 0);
  args = UINT32_TO_STREAM(args, 0x00000010 + ssid_len);
  args = UINT32_TO_STREAM(args, 0);
  args = UINT16_TO_STREAM(args, 0);

  /* Padding shall be zeroed */

  ARRAY_TO_STREAM(args, bssid_zero, ETH_ALEN);
  ARRAY_TO_STREAM(args, ssid, ssid_len);

  /* Initiate a HCI command */

  hci_command_send(HCI_CMND_WLAN_CONNECT, ptr, WLAN_CONNECT_PARAM_LEN +
                   ssid_len  - 1);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_CONNECT, &ret);
  errno = ret;

  cc3000_lib_unlock();

  return ret;
}
示例#24
0
long wlan_disconnect(void)
{
  long ret;
  uint8_t *ptr;

  cc3000_lib_lock();

  ret = EFAIL;
  ptr = tSLInformation.pucTxCommandBuffer;

  hci_command_send(HCI_CMND_WLAN_DISCONNECT, ptr, 0);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_DISCONNECT, &ret);
  set_errno(ret);

  cc3000_lib_unlock();

  return ret;
}
示例#25
0
long wlan_ioctl_statusget(void)
{
  long ret;
  uint8_t *ptr;

  cc3000_lib_lock();

  ret = EFAIL;
  ptr = tSLInformation.pucTxCommandBuffer;

  hci_command_send(HCI_CMND_WLAN_IOCTL_STATUSGET,
                   ptr, 0);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_STATUSGET, &ret);

  cc3000_lib_unlock();

  return ret;
}
示例#26
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;
}
示例#27
0
long netapp_ping_stop(void)
{
  int8_t scRet;
  uint8_t *ptr;

  cc3000_lib_lock();

  scRet = EFAIL;
  ptr = tSLInformation.pucTxCommandBuffer;

  /* Initiate a HCI command */

  hci_command_send(HCI_NETAPP_PING_STOP, ptr, 0);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_NETAPP_PING_STOP, &scRet);

  cc3000_lib_unlock();

  return(scRet);
}
示例#28
0
long wlan_smart_config_set_prefix(char* cNewPrefix)
{
  long ret;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

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

  if (cNewPrefix == NULL)
    {
      return ret;
    }

  /* With the new Smart Config, prefix must be TTT */

  else
    {
      *cNewPrefix = 'T';
      *(cNewPrefix + 1) = 'T';
      *(cNewPrefix + 2) = 'T';
    }

  ARRAY_TO_STREAM(args, cNewPrefix, SL_SIMPLE_CONFIG_PREFIX_LENGTH);

  hci_command_send(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, ptr,
                   SL_SIMPLE_CONFIG_PREFIX_LENGTH);

  /* Wait for command complete event */

  SimpleLinkWaitEvent(HCI_CMND_WLAN_IOCTL_SIMPLE_CONFIG_SET_PREFIX, &ret);

  cc3000_lib_unlock();

  return ret;
}
示例#29
0
void wlan_init(size_t max_tx_len,
               tWlanCB sWlanCB,
               tFWPatches sFWPatches,
               tDriverPatches sDriverPatches,
               tBootLoaderPatches sBootLoaderPatches)
{
  void *old = NULL;

  cc3000_lib_lock();
  tSLInformation.sFWPatches = sFWPatches;
  tSLInformation.sDriverPatches = sDriverPatches;
  tSLInformation.sBootLoaderPatches = sBootLoaderPatches;

  /* Allocate the memory for the RX/TX data transactions */

  if (tSLInformation.pucTxCommandBuffer != NULL)
    {
      old = tSLInformation.pucTxCommandBuffer;
    }

  tSLInformation.pucTxCommandBuffer = malloc(max_tx_len);
  tSLInformation.usrBuffer.pbuffer = &tSLInformation.pucTxCommandBuffer[MAX_HCI_CMD_LENGTH];
  tSLInformation.usrBuffer.len = max_tx_len - MAX_HCI_CMD_LENGTH;

  /* Init I/O callback */
  /* Init asynchronous events callback */

  tSLInformation.sWlanCB= sWlanCB;

  /* By default TX Complete events are routed to host too */

  tSLInformation.InformHostOnTxComplete = 1;
  cc3000_lib_unlock();

  if (old)
    {
      free(old);
    }
}
示例#30
0
signed long nvmem_read(unsigned long ulFileId, unsigned long ulLength,
                       unsigned long ulOffset, uint8_t *buff)
{
  uint8_t ucStatus = 0xff;
  uint8_t *ptr;
  uint8_t *args;

  cc3000_lib_lock();

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

  /* Fill in HCI packet structure */

  args = UINT32_TO_STREAM(args, ulFileId);
  args = UINT32_TO_STREAM(args, ulLength);
  args = UINT32_TO_STREAM(args, ulOffset);

  /* Initiate a HCI command */

  hci_command_send(HCI_CMND_NVMEM_READ, ptr, NVMEM_READ_PARAMS_LEN);
  SimpleLinkWaitEvent(HCI_CMND_NVMEM_READ, &ucStatus);

  /* In case there is data - read it - even if an error code is returned
   * Note: It is the user responsibility to ignore the data in case of an
   * error code
   */

  /* Wait for the data in a synchronous way. Here we assume that the buffer is
   * big enough to store also parameters of nvmem
   */

  SimpleLinkWaitData(buff, 0, &ucStatus);

  cc3000_lib_unlock();

  return ucStatus;
}