Host library for controlling a WiConnect enabled Wi-Fi module.

Dependents:   wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more

Revision:
6:8a87a59d0d21
Parent:
5:8d91a87ebba2
Child:
11:ea484e1b7fc4
--- a/internal/wiconnect/Wiconnect.cpp	Mon Aug 11 04:00:39 2014 -0700
+++ b/internal/wiconnect/Wiconnect.cpp	Mon Aug 11 13:55:07 2014 -0700
@@ -11,7 +11,6 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
-#include <assert.h>
 
 #include "WiconnectInterface.h"
 #include "internal/common.h"
@@ -48,7 +47,7 @@
 #ifdef WICONNECT_ENABLE_MALLOC
     if(internalBufferSize_ > 0 && internalBuffer_ == NULL)
     {
-        assert(_malloc != NULL);
+        wiconnect_assert(this, "Wiconnect(), malloc not defined", _malloc != NULL);
         internalBuffer = (char*)_malloc(internalBufferSize_);
         internalBufferAlloc = true;
     }
@@ -80,6 +79,9 @@
 Wiconnect::Wiconnect(const SerialConfig &serialConfig, void *internalBuffer, int internalBufferSize, Pin reset, Pin wake, bool nonBlocking MALLOC_ARGS) :
         NetworkInterface(this), SocketInterface(this), FileInterface(this), MALLOC_CONSTRUCTORS serial(serialConfig, this), resetGpio(reset), wakeGpio(wake)
 {
+#ifdef WICONNECT_ENABLE_MALLOC
+    wiconnect_assert(this, "Wiconnect(), bad malloc/free", (mallocPtr == NULL && freePtr == NULL) || (mallocPtr != NULL && freePtr != NULL));
+#endif
     prepare(internalBuffer, internalBufferSize, nonBlocking);
 }
 
@@ -87,6 +89,9 @@
 Wiconnect::Wiconnect(const SerialConfig &serialConfig, Pin reset, Pin wake, bool nonBlocking MALLOC_ARGS) :
     NetworkInterface(this), SocketInterface(this), FileInterface(this), MALLOC_CONSTRUCTORS serial(serialConfig, this), resetGpio(reset), wakeGpio(wake)
 {
+#ifdef WICONNECT_ENABLE_MALLOC
+    wiconnect_assert(this, "Wiconnect(), bad malloc/free", (mallocPtr == NULL && freePtr == NULL) || (mallocPtr != NULL && freePtr != NULL));
+#endif
     prepare(NULL, 0, nonBlocking);
 }
 
@@ -259,6 +264,12 @@
 }
 
 /*************************************************************************************************/
+void Wiconnect::setAssertLogger(LogFunc assertLogFunc)
+{
+    assertLogger = assertLogFunc;
+}
+
+/*************************************************************************************************/
 void Wiconnect::debugLog(const char *msg, ...)
 {
     if(!debugLogger.isValid())