Hexiwear library for communicating with the on-board KW40Z BLE device. KW40Z handles also the touch buttons.
Dependents: Hexi_Buttons_Example Hexi_Click_Relay-v2_Example Hexi_Click_Relay-v3_Example Hexi_Catch-the-dot_Game ... more
Diff: Hexi_KW40Z.cpp
- Revision:
- 6:23323e8aeda4
- Parent:
- 5:8c7c1cc024ed
- Child:
- 8:2b9b24f3154d
--- a/Hexi_KW40Z.cpp Tue Sep 20 22:38:58 2016 +0000 +++ b/Hexi_KW40Z.cpp Sun Sep 25 04:28:52 2016 +0000 @@ -39,7 +39,7 @@ RawSerial pc(USBTX, USBRX); // tx, rx #endif -KW40Z::KW40Z(PinName txPin,PinName rxPin) : device(txPin, rxPin), mainThread(&KW40Z::mainStarter, this, osPriorityNormal,1024), rxThread(&KW40Z::rxStarter, this, osPriorityNormal,1024) +KW40Z::KW40Z(PinName txPin,PinName rxPin) : device(txPin, rxPin), mainThread(osPriorityNormal,1024), rxThread(osPriorityNormal,1024) { #if defined (LIB_DEBUG) pc.baud(115200); @@ -71,8 +71,8 @@ bondPassKey = 0; /* intialization finalized, signal to start the threads */ - mainThread.signal_set(START_THREAD); - rxThread.signal_set(START_THREAD); + mainThread.start(this,&KW40Z::mainTask); + rxThread.start(this, &KW40Z::rxTask); } KW40Z::~KW40Z(void) @@ -88,31 +88,17 @@ void KW40Z::attach_passkey(passkey_t passkeyFct){ passkeyCb = passkeyFct; } void KW40Z::attach_notifications(notifications_t notFct) { notificationsCb = notFct; } -void KW40Z::rxStarter(void const *p) { - KW40Z *instance = (KW40Z*)p; - instance->rxTask(); -} - -void KW40Z::mainStarter(void const *p) { - KW40Z *instance = (KW40Z*)p; - instance->mainTask(); -} - void KW40Z::mainTask(void) { - mainThread.signal_wait(START_THREAD); - #if defined (LIB_DEBUG) pc.printf("MainTask Stared\r\n"); #endif - SendGetActiveTsiGroup(); SendGetAdvertisementMode(); SendGetLinkState(); SendGetVersion(); - while(1) { osEvent evt = queue.get(); @@ -127,8 +113,6 @@ void KW40Z::rxTask(void) { - rxThread.signal_wait(START_THREAD); - #if defined (LIB_DEBUG) pc.printf("RxTask Stared\r\n"); #endif @@ -706,5 +690,3 @@ { return activeTsiGroup; } - -