Statistics
| Branch: | Tag: | Revision:

amiro-os / include / amiro / bluetooth / checkutility.hpp @ 3a3d08d9

History | View | Annotate | Download (1.363 KB)

1
#ifndef AMIRO_WT12_CHECKUTILITY_H_
2
#define AMIRO_WT12_CHECKUTILITY_H_
3

    
4
#include <ch.hpp>
5

    
6
namespace amiro {
7

    
8
  class WT12CheckUtility
9
  {
10
  public:
11
    enum Constants {
12
      MUX_StartOfFrame = 0xBFu
13
    };
14

    
15
  private:
16
    struct Message {
17
      struct Head {
18
        uint8_t start_of_frame;
19
        uint8_t link_id;
20
        uint8_t flags;
21
        uint16_t length;
22
      };
23

    
24
      Head head;
25
      char* message;
26
      uint8_t n_link;
27
    };
28

    
29
  public:
30
    explicit WT12CheckUtility();
31
    ~WT12CheckUtility();
32

    
33
    void reset();
34
    bool waitForReady(const bool print = false);
35
    uint8_t selftest();
36
    void msgPrint(const char* message, const uint16_t length);
37
    void msgPrintMulti(const char* message_buf, const uint16_t* length_buf, const uint16_t num_messages);
38
    void sendMessage(char* message, uint8_t link_id = 0xFF);
39
    void sendMessageRaw(const char* message);
40
    uint16_t receiveMessage(char* message, const uint16_t max_length);
41
    uint16_t receiveMessages(char* message_buf, const uint16_t msg_buf_size, uint16_t* length_buf, const uint16_t len_buf_size, const char* last_msg, const char* filter_in = "", const char* filter_out = NULL);
42

    
43
    void receiveRaw(uint8_t* buffer, uint16_t num_bytes, const bool print = false);
44
    void receiveRawLine(const bool print = true);
45
    void clearMessageBuffer(const bool print = false);
46

    
47
  };
48
}
49

    
50
#endif // AMIRO_WT12_CHECKUTILITY_H_