Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
uwb_link/uwb_link_impl.h
- Committer:
- bhepp
- Date:
- 2016-04-06
- Revision:
- 3:bfc4928cd279
- Parent:
- 2:502d1a5f79a0
File content as of revision 3:bfc4928cd279:
//
// Simple message protocol for UWB.
//
// Created by Benjamin Hepp on 02.04.16.
// Copyright (c) 2016 Benjamin Hepp. All rights reserved.
//
#pragma once
#include <ait_link/ait_link_impl.h>
#include "uwb_link.h"
#include <iostream>
#ifdef __MBED__
#include "uwb_link_mbed.h"
#else
namespace ait {
// We need this extra base-class to ensure initialization of AITLinkImpl when initializing UWBLink in UWBLinkImpl
class UWBLinkImplBase {
public:
UWBLinkImplBase()
: _ait_link(&serial_) {
}
protected:
Serial serial_;
AITLinkImpl _ait_link;
};
class UWBLinkImpl : public UWBLinkImplBase, public UWBLink {
public:
UWBLinkImpl(int buffer_size = 1024)
: UWBLink(&_ait_link, buffer_size) {
serial_.setReadCallback(boost::bind(std::mem_fun(&UWBLink::inputReceivedChar), this, _1));
}
UWBLinkImpl(const std::string& device, unsigned int baud_rate, int buffer_size = 1024)
: UWBLink(&_ait_link, buffer_size) {
serial_.setReadCallback(boost::bind(std::mem_fun(&UWBLink::inputReceivedChar), this, _1));
start(device, baud_rate);
}
void start(const std::string& device, unsigned int baud_rate) {
serial_.open(device, baud_rate);
serial_.start();
}
};
}
#endif // __MBED__