Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Hexi_BLE_Example_Modified Hexi_BLE_Example_ModifiedPOTATO
Fork of Hexi_KW40Z by
Revision 14:241c491f985f, committed 2018-08-27
- Comitter:
- Xi Han
- Date:
- Mon Aug 27 16:15:26 2018 -0700
- Parent:
- 13:84ead63f7353
- Commit message:
- GM
Changed in this revision
| Hexi_KW40Z.cpp | Show annotated file Show diff for this revision Revisions of this file |
| Hexi_KW40Z.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/Hexi_KW40Z.cpp Thu Aug 09 22:45:01 2018 +0000
+++ b/Hexi_KW40Z.cpp Mon Aug 27 16:15:26 2018 -0700
@@ -35,7 +35,7 @@
#include "Hexi_KW40Z.h"
-KW40Z::KW40Z(PinName txPin,PinName rxPin) :
+KW40Z::KW40Z(PinName txPin,PinName rxPin) :
#if defined (LIB_DEBUG) || defined (RAW_DEBUG) || defined (RX_DEBUG)
pc(USBTX, USBRX),
#endif
@@ -70,6 +70,9 @@
advertisementMode = 0;
linkState = 0;
bondPassKey = 0;
+
+ allocated = 0;
+ freed = 0;
/* intialization finalized, signal to start the threads */
rxThread.start(this, &KW40Z::rxTask);
@@ -109,7 +112,10 @@
hostInterface_packet_t *packet = (hostInterface_packet_t*)evt.value.p;
ProcessPacket(packet);
mpool.free(packet);
+ // freed += 1;
+ // printf("%s%lu\r\n", "non-freed buffer slots: ", allocated - freed);
}
+
}
}
@@ -139,6 +145,13 @@
{
/* copy txPacket to the mem pool */
hostInterface_packet_t *packet = mpool.alloc();
+
+
+ if (packet == NULL) {
+ return;
+ }
+ allocated += 1;
+
memcpy(packet, txPacket, sizeof(hostInterface_packet_t));
/* Set the TX bit in the Start 2 byte */
@@ -154,6 +167,8 @@
printf("SendPacket: ");
DebugPrintPacket(packet);
#endif
+ // printf("SendPacket: ");
+ // DebugPrintPacket(packet);
/* send message to main task */
queue.put(packet);
@@ -255,6 +270,7 @@
/* send message to main task */
hostInterface_packet_t *rxPacket = mpool.alloc();
+ allocated += 1;
memcpy(rxPacket, &hostInterface_rxPacket, sizeof(hostInterface_packet_t));
queue.put(rxPacket);
@@ -265,6 +281,9 @@
#if defined (RAW_DEBUG)
printf("\r\n");
#endif
+ // printf("RX: ");
+ // DebugPrintPacket(&hostInterface_rxPacket);
+ // printf("\r\n");
/* reset buffer position */
rxBuff = (uint8_t*)&hostInterface_rxPacket;
}
@@ -775,3 +794,20 @@
printf("\r\n");
}
#endif
+// void KW40Z::DebugPrintPacket(hostInterface_packet_t * packet)
+// {
+// char * idx = (char *)packet;
+// uint8_t length = packet->length + gHostInterface_headerSize + 1;
+
+// if(length > sizeof(hostInterface_packet_t))
+// {
+// length = sizeof(hostInterface_packet_t);
+// }
+
+// for(uint8_t i = 0; i < length; i++)
+// {
+// printf("%02X ",*idx);
+// idx++;
+// }
+// printf("\r\n");
+// }
--- a/Hexi_KW40Z.h Thu Aug 09 22:45:01 2018 +0000
+++ b/Hexi_KW40Z.h Mon Aug 27 16:15:26 2018 -0700
@@ -124,8 +124,8 @@
packetType_sleepOFF = 35, /**< sleep OFF */
/* Message Service */
- packetType_messageIn = 116, /**< incoming alerts */
- packetType_messageOut = 117, /**< outcoming alerts */
+ packetType_messageIn = 116, /**< incoming messages */
+ packetType_messageOut = 117, /**< outcoming messages */
packetType_OK = 255 /**< OK packet */
} hostInterface_packetType_t;
@@ -258,9 +258,12 @@
uint8_t advertisementMode;
uint8_t linkState;
uint32_t bondPassKey;
+
+ uint32_t allocated;
+ uint32_t freed;
- MemoryPool<hostInterface_packet_t, 50> mpool;
- Queue<hostInterface_packet_t, 50> queue;
+ MemoryPool<hostInterface_packet_t, 500> mpool;
+ Queue<hostInterface_packet_t, 500> queue;
void mainTask(void);
void rxTask(void);
