Mavlink bridge for Mbed devices
mavlink_bridge.h@10:bd4a08d39e94, 2016-04-04 (annotated)
- Committer:
- bhepp
- Date:
- Mon Apr 04 11:18:57 2016 +0000
- Revision:
- 10:bd4a08d39e94
- Parent:
- 0:28183cc7963f
nop
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bhepp | 0:28183cc7963f | 1 | #pragma once |
bhepp | 0:28183cc7963f | 2 | |
bhepp | 0:28183cc7963f | 3 | #include "uart_interface.h" |
bhepp | 0:28183cc7963f | 4 | |
bhepp | 0:28183cc7963f | 5 | #include "mavlink_bridge/mavlink/v10/uwb/mavlink.h" |
bhepp | 0:28183cc7963f | 6 | |
bhepp | 0:28183cc7963f | 7 | namespace ait { |
bhepp | 0:28183cc7963f | 8 | |
bhepp | 0:28183cc7963f | 9 | class MAVLinkBridge { |
bhepp | 0:28183cc7963f | 10 | UART_Interface* _uart; |
bhepp | 0:28183cc7963f | 11 | mavlink_system_t _mavlink_system; |
bhepp | 0:28183cc7963f | 12 | // TODO: Is this int? |
bhepp | 0:28183cc7963f | 13 | mavlink_channel_t _mavlink_channel; |
bhepp | 0:28183cc7963f | 14 | mavlink_message_t _recv_msg; |
bhepp | 0:28183cc7963f | 15 | mavlink_status_t _recv_status; |
bhepp | 0:28183cc7963f | 16 | int _packet_drops; |
bhepp | 0:28183cc7963f | 17 | |
bhepp | 0:28183cc7963f | 18 | public: |
bhepp | 0:28183cc7963f | 19 | MAVLinkBridge(UART_Interface* uart, mavlink_channel_t mavlink_channel = MAVLINK_COMM_0, uint8_t sysid = 1, uint8_t compid = MAV_COMP_ID_UART_BRIDGE); |
bhepp | 0:28183cc7963f | 20 | |
bhepp | 0:28183cc7963f | 21 | void setSysId(uint8_t sysid) { |
bhepp | 0:28183cc7963f | 22 | _mavlink_system.sysid = sysid; |
bhepp | 0:28183cc7963f | 23 | } |
bhepp | 0:28183cc7963f | 24 | |
bhepp | 0:28183cc7963f | 25 | uint8_t getSysId() const { |
bhepp | 0:28183cc7963f | 26 | return _mavlink_system.sysid; |
bhepp | 0:28183cc7963f | 27 | } |
bhepp | 0:28183cc7963f | 28 | |
bhepp | 0:28183cc7963f | 29 | void setCompId(uint8_t compid) { |
bhepp | 0:28183cc7963f | 30 | _mavlink_system.compid = compid; |
bhepp | 0:28183cc7963f | 31 | } |
bhepp | 0:28183cc7963f | 32 | |
bhepp | 0:28183cc7963f | 33 | uint8_t getCompId() const { |
bhepp | 0:28183cc7963f | 34 | return _mavlink_system.compid; |
bhepp | 0:28183cc7963f | 35 | } |
bhepp | 0:28183cc7963f | 36 | |
bhepp | 0:28183cc7963f | 37 | void sendMessage(const mavlink_message_t& msg); |
bhepp | 0:28183cc7963f | 38 | |
bhepp | 0:28183cc7963f | 39 | bool tryReceiveMessage(); |
bhepp | 0:28183cc7963f | 40 | |
bhepp | 0:28183cc7963f | 41 | const mavlink_message_t& getLastReceivedMessage(); |
bhepp | 0:28183cc7963f | 42 | |
bhepp | 0:28183cc7963f | 43 | protected: |
bhepp | 0:28183cc7963f | 44 | void sendBuffer(const uint8_t* buf, uint16_t len); |
bhepp | 0:28183cc7963f | 45 | }; |
bhepp | 0:28183cc7963f | 46 | |
bhepp | 0:28183cc7963f | 47 | } |