2222 * to any use, copying or further distribution of this software.
2323 */
2424/*************************************************************************************************/
25+ #define DEBUG
26+
2527
2628#include <string.h>
2729#include "wsf_types.h"
@@ -278,17 +280,24 @@ static const attsCccSet_t tagCccSet[TAG_NUM_CCC_IDX] =
278280/*************************************************************************************************/
279281static void tagAlert (uint8_t alert )
280282{
283+ #ifdef DEBUG
284+ debug_print (__func__ , __FILE__ , __LINE__ );
285+ debug_printf ("alert: 0x%02X\n" , alert );
286+ #endif
281287 /* perform alert according to setting of alert alert */
282288 if (alert == CH_ALERT_LVL_NONE )
283289 {
290+ set_led_low ();
284291 AppUiAction (APP_UI_ALERT_CANCEL );
285292 }
286293 else if (alert == CH_ALERT_LVL_MILD )
287294 {
295+ set_led_high ();
288296 AppUiAction (APP_UI_ALERT_LOW );
289297 }
290298 else if (alert == CH_ALERT_LVL_HIGH )
291299 {
300+ set_led_high ();
292301 AppUiAction (APP_UI_ALERT_HIGH );
293302 }
294303}
@@ -308,6 +317,9 @@ static void tagSetup(dmEvt_t *pMsg);
308317/*************************************************************************************************/
309318static void tagDmCback (dmEvt_t * pDmEvt )
310319{
320+ #ifdef DEBUG
321+ debug_print (__func__ , __FILE__ , __LINE__ );
322+ #endif
311323 dmEvt_t * pMsg ;
312324 uint16_t len ;
313325
@@ -341,6 +353,9 @@ static void tagDmCback(dmEvt_t *pDmEvt)
341353/*************************************************************************************************/
342354static void tagAttCback (attEvt_t * pEvt )
343355{
356+ #ifdef DEBUG
357+ debug_print (__func__ , __FILE__ , __LINE__ );
358+ #endif
344359 attEvt_t * pMsg ;
345360
346361 if ((pMsg = WsfMsgAlloc (sizeof (attEvt_t ) + pEvt -> valueLen )) != NULL )
@@ -367,6 +382,9 @@ static void tagAttCback(attEvt_t *pEvt)
367382/*************************************************************************************************/
368383static void tagCccCback (attsCccEvt_t * pEvt )
369384{
385+ #ifdef DEBUG
386+ debug_print (__func__ , __FILE__ , __LINE__ );
387+ #endif
370388 attsCccEvt_t * pMsg ;
371389 appDbHdl_t dbHdl ;
372390
@@ -398,6 +416,9 @@ static uint8_t tagIasWriteCback(dmConnId_t connId, uint16_t handle, uint8_t oper
398416 uint16_t offset , uint16_t len , uint8_t * pValue ,
399417 attsAttr_t * pAttr )
400418{
419+ #ifdef DEBUG
420+ debug_print (__func__ , __FILE__ , __LINE__ );
421+ #endif
401422 ATT_TRACE_INFO3 ("tagIasWriteCback connId:%d handle:0x%04x op:0x%02x" ,
402423 connId , handle , operation );
403424 ATT_TRACE_INFO2 (" offset:0x%04x len:0x%04x" , offset , len );
@@ -420,6 +441,9 @@ static uint8_t tagIasWriteCback(dmConnId_t connId, uint16_t handle, uint8_t oper
420441/*************************************************************************************************/
421442static void tagOpen (dmEvt_t * pMsg )
422443{
444+ #ifdef DEBUG
445+ debug_print (__func__ , __FILE__ , __LINE__ );
446+ #endif
423447 /* Update peer address info */
424448 tagCb .addrType = pMsg -> connOpen .addrType ;
425449 BdaCpy (tagCb .peerAddr , pMsg -> connOpen .peerAddr );
@@ -438,6 +462,9 @@ static void tagOpen(dmEvt_t *pMsg)
438462/*************************************************************************************************/
439463static void tagClose (dmEvt_t * pMsg )
440464{
465+ #ifdef DEBUG
466+ debug_print (__func__ , __FILE__ , __LINE__ );
467+ #endif
441468 uint8_t * pVal ;
442469 uint16_t len ;
443470
@@ -473,6 +500,9 @@ static void tagClose(dmEvt_t *pMsg)
473500/*************************************************************************************************/
474501static void tagSecPairCmpl (dmEvt_t * pMsg )
475502{
503+ #ifdef DEBUG
504+ debug_print (__func__ , __FILE__ , __LINE__ );
505+ #endif
476506 appConnCb_t * pCb ;
477507 dmSecKey_t * pPeerKey ;
478508
@@ -506,6 +536,9 @@ static void tagSecPairCmpl(dmEvt_t *pMsg)
506536/*************************************************************************************************/
507537static void tagSetup (dmEvt_t * pMsg )
508538{
539+ #ifdef DEBUG
540+ debug_print (__func__ , __FILE__ , __LINE__ );
541+ #endif
509542 /* set advertising and scan response data for discoverable mode */
510543 AppAdvSetData (APP_ADV_DATA_DISCOVERABLE , sizeof (tagAdvDataDisc ), (uint8_t * ) tagAdvDataDisc );
511544 AppAdvSetData (APP_SCAN_DATA_DISCOVERABLE , sizeof (tagScanData ), (uint8_t * ) tagScanData );
@@ -531,6 +564,9 @@ static void tagSetup(dmEvt_t *pMsg)
531564/*************************************************************************************************/
532565static void tagValueUpdate (attEvt_t * pMsg )
533566{
567+ #ifdef DEBUG
568+ debug_print (__func__ , __FILE__ , __LINE__ );
569+ #endif
534570 if (pMsg -> hdr .status == ATT_SUCCESS )
535571 {
536572 // todo: add debugging statement here to see what's happening!
@@ -564,6 +600,9 @@ static void tagValueUpdate(attEvt_t *pMsg)
564600/*************************************************************************************************/
565601static void tagDiscGapCmpl (dmConnId_t connId )
566602{
603+ #ifdef DEBUG
604+ debug_print (__func__ , __FILE__ , __LINE__ );
605+ #endif
567606 appDbHdl_t dbHdl ;
568607
569608 /* if RPA Only attribute found on peer device */
@@ -588,6 +627,9 @@ static void tagDiscGapCmpl(dmConnId_t connId)
588627/*************************************************************************************************/
589628static void tagProcRssiTimer (dmEvt_t * pMsg )
590629{
630+ #ifdef DEBUG
631+ debug_print (__func__ , __FILE__ , __LINE__ );
632+ #endif
591633 dmConnId_t connId ;
592634
593635 /* if still connected */
@@ -614,6 +656,9 @@ static void tagProcRssiTimer(dmEvt_t *pMsg)
614656/*************************************************************************************************/
615657static void tagBtnCback (uint8_t btn )
616658{
659+ #ifdef DEBUG
660+ debug_print (__func__ , __FILE__ , __LINE__ );
661+ #endif
617662 dmConnId_t connId ;
618663
619664 /* button actions when connected */
@@ -763,6 +808,9 @@ static void tagBtnCback(uint8_t btn)
763808/*************************************************************************************************/
764809static void tagDiscCback (dmConnId_t connId , uint8_t status )
765810{
811+ #ifdef DEBUG
812+ debug_print (__func__ , __FILE__ , __LINE__ );
813+ #endif
766814 switch (status )
767815 {
768816 case APP_DISC_INIT :
@@ -856,6 +904,10 @@ static void tagDiscCback(dmConnId_t connId, uint8_t status)
856904/*************************************************************************************************/
857905static void tagProcMsg (dmEvt_t * pMsg )
858906{
907+ #ifdef DEBUG
908+ debug_print (__func__ , __FILE__ , __LINE__ );
909+ debug_printf ("pMsg->hdr.event: 0x%04X\n" , (uint32_t )pMsg -> hdr .event );
910+ #endif
859911 uint8_t uiEvent = APP_UI_NONE ;
860912
861913 switch (pMsg -> hdr .event )
@@ -987,6 +1039,9 @@ static void tagProcMsg(dmEvt_t *pMsg)
9871039/*************************************************************************************************/
9881040void NusHandlerInit (wsfHandlerId_t handlerId )
9891041{
1042+ #ifdef DEBUG
1043+ debug_print (__func__ , __FILE__ , __LINE__ );
1044+ #endif
9901045 APP_TRACE_INFO0 ("NusHandlerInit" );
9911046
9921047 /* store handler ID */
@@ -1030,6 +1085,9 @@ void NusHandlerInit(wsfHandlerId_t handlerId)
10301085/*************************************************************************************************/
10311086void NusHandler (wsfEventMask_t event , wsfMsgHdr_t * pMsg )
10321087{
1088+ #ifdef DEBUG
1089+ debug_print (__func__ , __FILE__ , __LINE__ );
1090+ #endif
10331091 if (pMsg != NULL )
10341092 {
10351093 APP_TRACE_INFO1 ("Tag got evt %d" , pMsg -> event );
@@ -1069,6 +1127,9 @@ void NusHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg)
10691127/*************************************************************************************************/
10701128void NusStart (void )
10711129{
1130+ #ifdef DEBUG
1131+ debug_print (__func__ , __FILE__ , __LINE__ );
1132+ #endif
10721133 /* Register for stack callbacks */
10731134 DmRegister (tagDmCback );
10741135 DmConnRegister (DM_CLIENT_ID_APP , tagDmCback );
0 commit comments