File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
libraries/Bluefruit52Lib/src/utility Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change 3636
3737#include " AdaMsg.h"
3838
39- AdaMsg::AdaMsg (void )
39+ void AdaMsg::_init (void )
4040{
4141 _dynamic = true ;
42+ _waiting = false ;
4243 _sem = NULL ;
4344
4445 buffer = NULL ;
4546 remaining = xferlen = 0 ;
4647}
4748
49+ AdaMsg::AdaMsg (void )
50+ {
51+ _init ();
52+ }
53+
4854// dynamic mean semaphore is malloced and freed only when in action
4955void AdaMsg::begin (bool dynamic)
5056{
@@ -58,6 +64,7 @@ void AdaMsg::begin(bool dynamic)
5864void AdaMsg::stop (void )
5965{
6066 if (!_dynamic) vSemaphoreDelete (_sem);
67+ _init ();
6168}
6269
6370void AdaMsg::prepare (void * buf, uint16_t bufsize)
@@ -82,10 +89,12 @@ int32_t AdaMsg::waitUntilComplete(uint32_t ms)
8289
8390 int result = -1 ;
8491
92+ _waiting = true ;
8593 if ( xSemaphoreTake (_sem, ms2tick (ms) ) )
8694 {
8795 result = xferlen;
8896 }
97+ _waiting = false ;
8998
9099 if (_dynamic)
91100 {
@@ -96,6 +105,11 @@ int32_t AdaMsg::waitUntilComplete(uint32_t ms)
96105 return result;
97106}
98107
108+ bool AdaMsg::isWaiting (void )
109+ {
110+ return _waiting;
111+ }
112+
99113uint16_t AdaMsg::feed (void * data, uint16_t len)
100114{
101115 len = min16 (len, remaining);
Original file line number Diff line number Diff line change @@ -42,8 +42,11 @@ class AdaMsg
4242{
4343 private:
4444 bool _dynamic;
45+ volatile bool _waiting;
4546 SemaphoreHandle_t _sem;
4647
48+ void _init (void );
49+
4750 public:
4851 uint8_t * buffer;
4952 uint16_t remaining;
@@ -57,6 +60,7 @@ class AdaMsg
5760
5861 void prepare (void * buf, uint16_t bufsize);
5962 int32_t waitUntilComplete (uint32_t ms);
63+ bool isWaiting (void );
6064
6165 uint16_t feed (void * data, uint16_t len);
6266 void complete (void );
You can’t perform that action at this time.
0 commit comments