TI's CC3100. A test demo with very little testing done!
Diff: main.cpp
- Revision:
- 3:b89198ac2efe
- Parent:
- 0:e89ba455dbcf
- Child:
- 5:d3b320ebd469
--- a/main.cpp Sun Feb 15 11:01:37 2015 +0000
+++ b/main.cpp Sun Feb 22 18:33:10 2015 +0000
@@ -50,13 +50,12 @@
#include "cc3100_sl_common.h"
#include "fPtr_func.h"
+#include "cc3100.h"
#include "cc3100_spi.h"
#include "myBoardInit.h"
using namespace mbed_cc3100;
-class cc3100_netcfg *_netcfg;
-
#if (THIS_BOARD == MBED_BOARD_LPC1768)
//cc3100 _cc3100(p9, p10, p8, SPI(p5, p6, p7));//LPC1768 irq, nHib, cs, mosi, miso, sck
cc3100 _cc3100(p9, p10, p8, SPI(p11, p12, p13));//LPC1768 irq, nHib, cs, mosi, miso, sck
@@ -82,7 +81,7 @@
/*
* GLOBAL VARIABLES -- Start
*/
-int32_t demo = 1;
+int32_t demo = 0;
/*
* GLOBAL VARIABLES -- End
@@ -119,7 +118,7 @@
_cc3100.CLR_STATUS_BIT(g_Status, STATUS_BIT_PING_DONE);
g_PingPacketsRecv = 0;
-
+
/*
* Following function configures the device to default state by cleaning
* the persistent settings stored in NVMEM (viz. connection profiles &
@@ -209,11 +208,11 @@
if (ROLE_AP == role) {
/* If the device is in AP mode, we need to wait for this event before doing anything */
while(!_cc3100.IS_IP_ACQUIRED(g_Status,STATUS_BIT_IP_ACQUIRED)) {
- _cc3100.SlNonOsMainLoopTask();
+ _cc3100._nonos._SlNonOsMainLoopTask();
}
} else {
/* Configure CC3100 to start in AP mode */
- retVal = _cc3100.WlanSetMode(ROLE_AP);
+ retVal = _cc3100._wlan.sl_WlanSetMode(ROLE_AP);
if(retVal < 0)
LOOP_FOREVER();
@@ -227,7 +226,7 @@
if (ROLE_AP == role) {
/* If the device is in AP mode, we need to wait for this event before doing anything */
while(!_cc3100.IS_IP_ACQUIRED(g_Status,STATUS_BIT_IP_ACQUIRED)) {
- _cc3100.SlNonOsMainLoopTask();
+ _cc3100._nonos._SlNonOsMainLoopTask();
}
} else {
printf(" Device couldn't be configured in AP mode \n\r");
@@ -238,36 +237,36 @@
printf(" Ready to configue SSID\r\n");
/* Configure the SSID of the CC3100 */
- retVal = _cc3100.WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(SSID_AP_MODE), (uint8_t *)SSID_AP_MODE);
+ retVal = _cc3100._wlan.sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(SSID_AP_MODE), (uint8_t *)SSID_AP_MODE);
if(retVal < 0)
LOOP_FOREVER();
SecType = SEC_TYPE_AP_MODE;
/* Configure the Security parameter the AP mode */
- retVal = _cc3100.WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (uint8_t *)&SecType);
+ retVal = _cc3100._wlan.sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SECURITY_TYPE, 1, (uint8_t *)&SecType);
if(retVal < 0)
LOOP_FOREVER();
- retVal = _cc3100.WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(PASSWORD_AP_MODE), (uint8_t *)PASSWORD_AP_MODE);
+ retVal = _cc3100._wlan.sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_PASSWORD, strlen(PASSWORD_AP_MODE), (uint8_t *)PASSWORD_AP_MODE);
if(retVal < 0){
LOOP_FOREVER();
}
- ipV4.ipV4 = _netcfg->SL_IPV4_VAL(192,168,0,1);//CONFIG_IP;
- ipV4.ipV4Mask = _netcfg->SL_IPV4_VAL(255,255,255,0);//CONFIG_MASK;
- ipV4.ipV4Gateway = _netcfg->SL_IPV4_VAL(192,168,0,1);//CONFIG_GATEWAY;
- ipV4.ipV4DnsServer = _netcfg->SL_IPV4_VAL(192,168,0,1);//CONFIG_DNS;
+ ipV4.ipV4 = _cc3100._netcfg.SL_IPV4_VAL(192,168,0,1);//CONFIG_IP;
+ ipV4.ipV4Mask = _cc3100._netcfg.SL_IPV4_VAL(255,255,255,0);//CONFIG_MASK;
+ ipV4.ipV4Gateway = _cc3100._netcfg.SL_IPV4_VAL(192,168,0,1);//CONFIG_GATEWAY;
+ ipV4.ipV4DnsServer = _cc3100._netcfg.SL_IPV4_VAL(192,168,0,1);//CONFIG_DNS;
/* Configure the Static IP */
- retVal = _cc3100.NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,1,sizeof(SlNetCfgIpV4Args_t), (uint8_t *)&ipV4);
+ retVal = _cc3100._netcfg.sl_NetCfgSet(SL_IPV4_AP_P2P_GO_STATIC_ENABLE,1,sizeof(SlNetCfgIpV4Args_t), (uint8_t *)&ipV4);
if(retVal < 0)
LOOP_FOREVER();
dhcpParams.lease_time = IP_LEASE_TIME;
- dhcpParams.ipv4_addr_start = _netcfg->SL_IPV4_VAL(192,168,0,100);//DHCP_START_IP;
- dhcpParams.ipv4_addr_last = _netcfg->SL_IPV4_VAL(192,168,0,200);//DHCP_END_IP;
+ dhcpParams.ipv4_addr_start = _cc3100._netcfg.SL_IPV4_VAL(192,168,0,100);//DHCP_START_IP;
+ dhcpParams.ipv4_addr_last = _cc3100._netcfg.SL_IPV4_VAL(192,168,0,200);//DHCP_END_IP;
- retVal = _cc3100.NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, sizeof(SlNetAppDhcpServerBasicOpt_t), (uint8_t*)&dhcpParams);
+ retVal = _cc3100._netapp.sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, sizeof(SlNetAppDhcpServerBasicOpt_t), (uint8_t*)&dhcpParams);
if(retVal < 0)
LOOP_FOREVER();
@@ -283,7 +282,7 @@
if (ROLE_AP == role) {
/* If the device is in AP mode, we need to wait for this event before doing anything */
while(!_cc3100.IS_IP_ACQUIRED(g_Status,STATUS_BIT_IP_ACQUIRED)) {
- _cc3100.SlNonOsMainLoopTask();
+ _cc3100._nonos._SlNonOsMainLoopTask();
}
} else {
printf(" Device couldn't enter AP mode \n\r");
@@ -294,7 +293,7 @@
/* Wait */
printf(" Waiting for clients to connect...!\n\r");
while((!_cc3100.IS_IP_LEASED(g_Status,STATUS_BIT_IP_LEASED)) || (!_cc3100.IS_STA_CONNECTED(g_Status,STATUS_BIT_STA_CONNECTED))) {
- _cc3100.SlNonOsMainLoopTask();
+ _cc3100._nonos._SlNonOsMainLoopTask();
}
printf(" Client connected to the device \n\r");
printf(" Pinging...! \n\r");
@@ -308,13 +307,13 @@
PingParams.Ip = g_StationIP; /* Fill the station IP address connected to CC3100 */
/* Ping client connected to CC3100 */
- retVal = _cc3100.NetAppPingStart((SlPingStartCommand_t*)&PingParams, SL_AF_INET, (SlPingReport_t*)&Report, &SimpleLinkPingReport);
+ retVal = _cc3100._netapp.sl_NetAppPingStart((SlPingStartCommand_t*)&PingParams, SL_AF_INET, (SlPingReport_t*)&Report, &SimpleLinkPingReport);
if(retVal < 0)
LOOP_FOREVER();
/* Wait */
while(!_cc3100.IS_PING_DONE(g_Status,STATUS_BIT_PING_DONE)) {
- _cc3100.SlNonOsMainLoopTask();
+ _cc3100._nonos._SlNonOsMainLoopTask();
}
if (0 == g_PingPacketsRecv) {