apps/examples/cc3000 updated by David Sidrane
This commit is contained in:
parent
eb39b81b69
commit
ea93f20f39
@ -699,4 +699,5 @@
|
|||||||
statement. From Martin Lederhilger (2013-10-24).
|
statement. From Martin Lederhilger (2013-10-24).
|
||||||
* apps/examples/adc: Add support so that a ADC driven by
|
* apps/examples/adc: Add support so that a ADC driven by
|
||||||
software triggering can be tested (2013-10-25).
|
software triggering can be tested (2013-10-25).
|
||||||
|
* apps/examples/cc3000: Updates from David Sidrane (2013-10-25).
|
||||||
|
|
||||||
|
@ -41,11 +41,11 @@ include $(APPDIR)/Make.defs
|
|||||||
|
|
||||||
APPNAME = c3b
|
APPNAME = c3b
|
||||||
PRIORITY = SCHED_PRIORITY_DEFAULT
|
PRIORITY = SCHED_PRIORITY_DEFAULT
|
||||||
STACKSIZE = 2048
|
STACKSIZE = 660
|
||||||
|
|
||||||
APPNAME1 = shell
|
APPNAME1 = shell
|
||||||
PRIORITY1 = SCHED_PRIORITY_DEFAULT
|
PRIORITY1 = SCHED_PRIORITY_DEFAULT
|
||||||
STACKSIZE1 = 2048
|
STACKSIZE1 = 980
|
||||||
|
|
||||||
# Hello, World! Example
|
# Hello, World! Example
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@ void CC3000_Init(void)
|
|||||||
once = true;
|
once = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
CC3000_wlan_init( CC3000_AsyncCallback,
|
cc3000_wlan_init( CC3000_AsyncCallback,
|
||||||
SendFirmwarePatch,
|
SendFirmwarePatch,
|
||||||
SendDriverPatch,
|
SendDriverPatch,
|
||||||
SendBootloaderPatch);
|
SendBootloaderPatch);
|
||||||
|
@ -87,14 +87,17 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include "board.h"
|
#include "board.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <syslog.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/wireless/cc3000/nvmem.h>
|
#include <nuttx/wireless/cc3000/nvmem.h>
|
||||||
#include <nuttx/wireless/cc3000/include/sys/socket.h>
|
#include <nuttx/wireless/cc3000/include/sys/socket.h>
|
||||||
#include <nuttx/wireless/cc3000/wlan.h>
|
#include <nuttx/wireless/cc3000/wlan.h>
|
||||||
@ -127,16 +130,60 @@ void ShowInformation(void);
|
|||||||
#define US_PER_SEC 1000000
|
#define US_PER_SEC 1000000
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Variables
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
uint8_t isInitialized = false;
|
static uint8_t isInitialized = false;
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
|
||||||
|
static struct mallinfo mmstart;
|
||||||
|
static struct mallinfo mmprevious;
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Private Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
bool wait(long timeoutMs, volatile unsigned long *what, volatile unsigned long is)
|
#ifndef CONFIG_EXAMPLE_CC3000_MEM_CHECK
|
||||||
|
# define stkmon_disp()
|
||||||
|
#else
|
||||||
|
static void show_memory_usage(struct mallinfo *mmbefore,
|
||||||
|
struct mallinfo *mmafter)
|
||||||
|
{
|
||||||
|
int diff;
|
||||||
|
|
||||||
|
printf(" total used free largest\n");
|
||||||
|
printf("Before:%11d%11d%11d%11d\n",
|
||||||
|
mmbefore->arena, mmbefore->uordblks, mmbefore->fordblks, mmbefore->mxordblk);
|
||||||
|
printf("After: %11d%11d%11d%11d\n",
|
||||||
|
mmafter->arena, mmafter->uordblks, mmafter->fordblks, mmafter->mxordblk);
|
||||||
|
|
||||||
|
diff = mmbefore->uordblks - mmafter->uordblks;
|
||||||
|
if (diff < 0)
|
||||||
|
{
|
||||||
|
printf("Change:%11d allocated\n", -diff);
|
||||||
|
}
|
||||||
|
else if (diff > 0)
|
||||||
|
{
|
||||||
|
printf("Change:%11d freed\n", diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
stkmon_disp();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _stkmon_disp(FAR struct tcb_s *tcb, FAR void *arg)
|
||||||
|
{
|
||||||
|
#if CONFIG_TASK_NAME_SIZE > 0
|
||||||
|
syslog("%5d %6d %6d %s\n",
|
||||||
|
tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb), tcb->name);
|
||||||
|
#else
|
||||||
|
syslog("%5d %6d %6d\n",
|
||||||
|
tcb->pid, tcb->adj_stack_size, up_check_tcbstack(tcb));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool wait(long timeoutMs, volatile unsigned long *what,
|
||||||
|
volatile unsigned long is)
|
||||||
{
|
{
|
||||||
long t_ms;
|
long t_ms;
|
||||||
struct timeval end, start;
|
struct timeval end, start;
|
||||||
@ -157,7 +204,8 @@ bool wait(long timeoutMs, volatile unsigned long *what, volatile unsigned long i
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wait_on(long timeoutMs, volatile unsigned long *what, volatile unsigned long is,char * msg)
|
static bool wait_on(long timeoutMs, volatile unsigned long *what,
|
||||||
|
volatile unsigned long is, char * msg)
|
||||||
{
|
{
|
||||||
printf(msg);
|
printf(msg);
|
||||||
printf("...");
|
printf("...");
|
||||||
@ -176,6 +224,21 @@ bool wait_on(long timeoutMs, volatile unsigned long *what, volatile unsigned lon
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void stkmon_disp(void)
|
||||||
|
{
|
||||||
|
#if CONFIG_TASK_NAME_SIZE > 0
|
||||||
|
syslog("%-5s %-6s %-6s %s\n", "PID", "SIZE", "USED", "THREAD NAME");
|
||||||
|
#else
|
||||||
|
syslog("%-5s %-6s %-6s\n", "PID", "SIZE", "USED");
|
||||||
|
#endif
|
||||||
|
sched_foreach(_stkmon_disp, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void AsyncEventPrint(void)
|
void AsyncEventPrint(void)
|
||||||
{
|
{
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -283,7 +346,16 @@ int execute(int cmd)
|
|||||||
{
|
{
|
||||||
Initialize();
|
Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
|
||||||
|
mmprevious= mallinfo();
|
||||||
|
show_memory_usage(&mmstart,&mmprevious);
|
||||||
|
#endif
|
||||||
shell_main(0, 0);
|
shell_main(0, 0);
|
||||||
|
#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
|
||||||
|
mmprevious= mallinfo();
|
||||||
|
show_memory_usage(&mmstart,&mmprevious);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'q':
|
case 'q':
|
||||||
@ -301,6 +373,12 @@ int execute(int cmd)
|
|||||||
|
|
||||||
void Initialize(void)
|
void Initialize(void)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
|
||||||
|
mmstart = mallinfo();
|
||||||
|
memcpy(&mmprevious, &mmstart, sizeof(struct mallinfo));
|
||||||
|
show_memory_usage(&mmstart,&mmprevious);
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t fancyBuffer[MAC_ADDR_LEN];
|
uint8_t fancyBuffer[MAC_ADDR_LEN];
|
||||||
|
|
||||||
if (isInitialized)
|
if (isInitialized)
|
||||||
@ -350,6 +428,11 @@ void Initialize(void)
|
|||||||
#else
|
#else
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
|
||||||
|
mmprevious = mallinfo();
|
||||||
|
show_memory_usage(&mmstart,&mmprevious);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This just shows the compiled size of the transmit & recieve buffers */
|
/* This just shows the compiled size of the transmit & recieve buffers */
|
||||||
@ -486,7 +569,7 @@ void StartSmartConfig(void)
|
|||||||
* returns is the socket number it used. So we ignore it.
|
* returns is the socket number it used. So we ignore it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
mdnsAdvertiser(1,device_name,strlen(device_name));
|
mdnsadvertiser(1, device_name, strlen(device_name));
|
||||||
|
|
||||||
printf(" Smart Config finished Successfully!\n");
|
printf(" Smart Config finished Successfully!\n");
|
||||||
ShowInformation();
|
ShowInformation();
|
||||||
@ -853,6 +936,7 @@ int c3b_main(int argc, char *argv[])
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
helpme();
|
helpme();
|
||||||
|
stkmon_disp();
|
||||||
|
|
||||||
ch = getchar();
|
ch = getchar();
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include <apps/netutils/uiplib.h>
|
#include <apps/netutils/uiplib.h>
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
#include <apps/nsh.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Definitions
|
* Definitions
|
||||||
@ -121,6 +122,9 @@ static void shell_unknown(int argc, char **argv)
|
|||||||
static void shell_quit(int argc, char **argv)
|
static void shell_quit(int argc, char **argv)
|
||||||
{
|
{
|
||||||
printf("Bye!\n");
|
printf("Bye!\n");
|
||||||
|
#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
|
||||||
|
stkmon_disp();
|
||||||
|
#endif
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,6 +167,9 @@ int shell_session(int argc, char *argv[])
|
|||||||
|
|
||||||
printf("CC3000 command shell -- NuttX style\n");
|
printf("CC3000 command shell -- NuttX style\n");
|
||||||
printf("Type '?' and return for help\n");
|
printf("Type '?' and return for help\n");
|
||||||
|
#ifdef CONFIG_EXAMPLE_CC3000_MEM_CHECK
|
||||||
|
stkmon_disp();
|
||||||
|
#endif
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
@ -210,7 +217,7 @@ int shell_main(int argc, char *argv[])
|
|||||||
config.d_stacksize = CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE;
|
config.d_stacksize = CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE;
|
||||||
config.t_priority = CONFIG_EXAMPLES_TELNETD_CLIENTPRIO;
|
config.t_priority = CONFIG_EXAMPLES_TELNETD_CLIENTPRIO;
|
||||||
config.t_stacksize = CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE;
|
config.t_stacksize = CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE;
|
||||||
config.t_entry = shell_session;
|
config.t_entry = nsh_consolemain;
|
||||||
|
|
||||||
/* Start the telnet daemon */
|
/* Start the telnet daemon */
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE
|
#ifndef CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE
|
||||||
# define CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE 768
|
# define CONFIG_EXAMPLES_TELNETD_DAEMONSTACKSIZE 580
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_EXAMPLES_TELNETD_CLIENTPRIO
|
#ifndef CONFIG_EXAMPLES_TELNETD_CLIENTPRIO
|
||||||
@ -70,6 +70,8 @@
|
|||||||
# define CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE 990
|
# define CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE 990
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#undef CONFIG_EXAMPLE_CC3000_MEM_CHECK
|
||||||
|
|
||||||
/* Other definitions ********************************************************/
|
/* Other definitions ********************************************************/
|
||||||
|
|
||||||
#define SHELL_PROMPT "CC3000 1.0> "
|
#define SHELL_PROMPT "CC3000 1.0> "
|
||||||
|
@ -159,15 +159,8 @@ static int telnetd_daemon(int argc, char *argv[])
|
|||||||
ndbg("listen failure %d\n", errno);
|
ndbg("listen failure %d\n", errno);
|
||||||
goto errout_with_socket;
|
goto errout_with_socket;
|
||||||
}
|
}
|
||||||
#if defined(CC3000_SOCKETS)
|
|
||||||
short nonBlocking=SOCK_OFF;
|
/* Now go silent. Only the lldbg family of debug functions should
|
||||||
if (setsockopt(listensd, SOL_SOCKET, SOCKOPT_ACCEPT_NONBLOCK, &nonBlocking, sizeof(nonBlocking)) < 0)
|
|
||||||
{
|
|
||||||
ndbg("setsockopt failure %d\n", errno);
|
|
||||||
goto errout_with_socket;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* Now go silent. Only the lldbg family of debug functions should
|
|
||||||
* be used after this point because these do not depend on stdout
|
* be used after this point because these do not depend on stdout
|
||||||
* being available.
|
* being available.
|
||||||
*/
|
*/
|
||||||
@ -259,10 +252,6 @@ static int telnetd_daemon(int argc, char *argv[])
|
|||||||
close(0);
|
close(0);
|
||||||
close(1);
|
close(1);
|
||||||
close(2);
|
close(2);
|
||||||
#if defined(CC3000_SOCKETS_ST)
|
|
||||||
/* We can not do more then one accept in Single treaded version */
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errout_with_acceptsd:
|
errout_with_acceptsd:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user