22
22
* to any use, copying or further distribution of this software.
23
23
*/
24
24
/*************************************************************************************************/
25
+ #define DEBUG
26
+
25
27
26
28
#include <string.h>
27
29
#include "wsf_types.h"
@@ -278,17 +280,24 @@ static const attsCccSet_t tagCccSet[TAG_NUM_CCC_IDX] =
278
280
/*************************************************************************************************/
279
281
static void tagAlert (uint8_t alert )
280
282
{
283
+ #ifdef DEBUG
284
+ debug_print (__func__ , __FILE__ , __LINE__ );
285
+ debug_printf ("alert: 0x%02X\n" , alert );
286
+ #endif
281
287
/* perform alert according to setting of alert alert */
282
288
if (alert == CH_ALERT_LVL_NONE )
283
289
{
290
+ set_led_low ();
284
291
AppUiAction (APP_UI_ALERT_CANCEL );
285
292
}
286
293
else if (alert == CH_ALERT_LVL_MILD )
287
294
{
295
+ set_led_high ();
288
296
AppUiAction (APP_UI_ALERT_LOW );
289
297
}
290
298
else if (alert == CH_ALERT_LVL_HIGH )
291
299
{
300
+ set_led_high ();
292
301
AppUiAction (APP_UI_ALERT_HIGH );
293
302
}
294
303
}
@@ -308,6 +317,9 @@ static void tagSetup(dmEvt_t *pMsg);
308
317
/*************************************************************************************************/
309
318
static void tagDmCback (dmEvt_t * pDmEvt )
310
319
{
320
+ #ifdef DEBUG
321
+ debug_print (__func__ , __FILE__ , __LINE__ );
322
+ #endif
311
323
dmEvt_t * pMsg ;
312
324
uint16_t len ;
313
325
@@ -341,6 +353,9 @@ static void tagDmCback(dmEvt_t *pDmEvt)
341
353
/*************************************************************************************************/
342
354
static void tagAttCback (attEvt_t * pEvt )
343
355
{
356
+ #ifdef DEBUG
357
+ debug_print (__func__ , __FILE__ , __LINE__ );
358
+ #endif
344
359
attEvt_t * pMsg ;
345
360
346
361
if ((pMsg = WsfMsgAlloc (sizeof (attEvt_t ) + pEvt -> valueLen )) != NULL )
@@ -367,6 +382,9 @@ static void tagAttCback(attEvt_t *pEvt)
367
382
/*************************************************************************************************/
368
383
static void tagCccCback (attsCccEvt_t * pEvt )
369
384
{
385
+ #ifdef DEBUG
386
+ debug_print (__func__ , __FILE__ , __LINE__ );
387
+ #endif
370
388
attsCccEvt_t * pMsg ;
371
389
appDbHdl_t dbHdl ;
372
390
@@ -398,6 +416,9 @@ static uint8_t tagIasWriteCback(dmConnId_t connId, uint16_t handle, uint8_t oper
398
416
uint16_t offset , uint16_t len , uint8_t * pValue ,
399
417
attsAttr_t * pAttr )
400
418
{
419
+ #ifdef DEBUG
420
+ debug_print (__func__ , __FILE__ , __LINE__ );
421
+ #endif
401
422
ATT_TRACE_INFO3 ("tagIasWriteCback connId:%d handle:0x%04x op:0x%02x" ,
402
423
connId , handle , operation );
403
424
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
420
441
/*************************************************************************************************/
421
442
static void tagOpen (dmEvt_t * pMsg )
422
443
{
444
+ #ifdef DEBUG
445
+ debug_print (__func__ , __FILE__ , __LINE__ );
446
+ #endif
423
447
/* Update peer address info */
424
448
tagCb .addrType = pMsg -> connOpen .addrType ;
425
449
BdaCpy (tagCb .peerAddr , pMsg -> connOpen .peerAddr );
@@ -438,6 +462,9 @@ static void tagOpen(dmEvt_t *pMsg)
438
462
/*************************************************************************************************/
439
463
static void tagClose (dmEvt_t * pMsg )
440
464
{
465
+ #ifdef DEBUG
466
+ debug_print (__func__ , __FILE__ , __LINE__ );
467
+ #endif
441
468
uint8_t * pVal ;
442
469
uint16_t len ;
443
470
@@ -473,6 +500,9 @@ static void tagClose(dmEvt_t *pMsg)
473
500
/*************************************************************************************************/
474
501
static void tagSecPairCmpl (dmEvt_t * pMsg )
475
502
{
503
+ #ifdef DEBUG
504
+ debug_print (__func__ , __FILE__ , __LINE__ );
505
+ #endif
476
506
appConnCb_t * pCb ;
477
507
dmSecKey_t * pPeerKey ;
478
508
@@ -506,6 +536,9 @@ static void tagSecPairCmpl(dmEvt_t *pMsg)
506
536
/*************************************************************************************************/
507
537
static void tagSetup (dmEvt_t * pMsg )
508
538
{
539
+ #ifdef DEBUG
540
+ debug_print (__func__ , __FILE__ , __LINE__ );
541
+ #endif
509
542
/* set advertising and scan response data for discoverable mode */
510
543
AppAdvSetData (APP_ADV_DATA_DISCOVERABLE , sizeof (tagAdvDataDisc ), (uint8_t * ) tagAdvDataDisc );
511
544
AppAdvSetData (APP_SCAN_DATA_DISCOVERABLE , sizeof (tagScanData ), (uint8_t * ) tagScanData );
@@ -531,6 +564,9 @@ static void tagSetup(dmEvt_t *pMsg)
531
564
/*************************************************************************************************/
532
565
static void tagValueUpdate (attEvt_t * pMsg )
533
566
{
567
+ #ifdef DEBUG
568
+ debug_print (__func__ , __FILE__ , __LINE__ );
569
+ #endif
534
570
if (pMsg -> hdr .status == ATT_SUCCESS )
535
571
{
536
572
// todo: add debugging statement here to see what's happening!
@@ -564,6 +600,9 @@ static void tagValueUpdate(attEvt_t *pMsg)
564
600
/*************************************************************************************************/
565
601
static void tagDiscGapCmpl (dmConnId_t connId )
566
602
{
603
+ #ifdef DEBUG
604
+ debug_print (__func__ , __FILE__ , __LINE__ );
605
+ #endif
567
606
appDbHdl_t dbHdl ;
568
607
569
608
/* if RPA Only attribute found on peer device */
@@ -588,6 +627,9 @@ static void tagDiscGapCmpl(dmConnId_t connId)
588
627
/*************************************************************************************************/
589
628
static void tagProcRssiTimer (dmEvt_t * pMsg )
590
629
{
630
+ #ifdef DEBUG
631
+ debug_print (__func__ , __FILE__ , __LINE__ );
632
+ #endif
591
633
dmConnId_t connId ;
592
634
593
635
/* if still connected */
@@ -614,6 +656,9 @@ static void tagProcRssiTimer(dmEvt_t *pMsg)
614
656
/*************************************************************************************************/
615
657
static void tagBtnCback (uint8_t btn )
616
658
{
659
+ #ifdef DEBUG
660
+ debug_print (__func__ , __FILE__ , __LINE__ );
661
+ #endif
617
662
dmConnId_t connId ;
618
663
619
664
/* button actions when connected */
@@ -763,6 +808,9 @@ static void tagBtnCback(uint8_t btn)
763
808
/*************************************************************************************************/
764
809
static void tagDiscCback (dmConnId_t connId , uint8_t status )
765
810
{
811
+ #ifdef DEBUG
812
+ debug_print (__func__ , __FILE__ , __LINE__ );
813
+ #endif
766
814
switch (status )
767
815
{
768
816
case APP_DISC_INIT :
@@ -856,6 +904,10 @@ static void tagDiscCback(dmConnId_t connId, uint8_t status)
856
904
/*************************************************************************************************/
857
905
static void tagProcMsg (dmEvt_t * pMsg )
858
906
{
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
859
911
uint8_t uiEvent = APP_UI_NONE ;
860
912
861
913
switch (pMsg -> hdr .event )
@@ -987,6 +1039,9 @@ static void tagProcMsg(dmEvt_t *pMsg)
987
1039
/*************************************************************************************************/
988
1040
void NusHandlerInit (wsfHandlerId_t handlerId )
989
1041
{
1042
+ #ifdef DEBUG
1043
+ debug_print (__func__ , __FILE__ , __LINE__ );
1044
+ #endif
990
1045
APP_TRACE_INFO0 ("NusHandlerInit" );
991
1046
992
1047
/* store handler ID */
@@ -1030,6 +1085,9 @@ void NusHandlerInit(wsfHandlerId_t handlerId)
1030
1085
/*************************************************************************************************/
1031
1086
void NusHandler (wsfEventMask_t event , wsfMsgHdr_t * pMsg )
1032
1087
{
1088
+ #ifdef DEBUG
1089
+ debug_print (__func__ , __FILE__ , __LINE__ );
1090
+ #endif
1033
1091
if (pMsg != NULL )
1034
1092
{
1035
1093
APP_TRACE_INFO1 ("Tag got evt %d" , pMsg -> event );
@@ -1069,6 +1127,9 @@ void NusHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg)
1069
1127
/*************************************************************************************************/
1070
1128
void NusStart (void )
1071
1129
{
1130
+ #ifdef DEBUG
1131
+ debug_print (__func__ , __FILE__ , __LINE__ );
1132
+ #endif
1072
1133
/* Register for stack callbacks */
1073
1134
DmRegister (tagDmCback );
1074
1135
DmConnRegister (DM_CLIENT_ID_APP , tagDmCback );
0 commit comments