Newer
Older
#include "GeoNetworkingLayer.hh"
#include "GeoNetworkingTypes.hh"
#include "loggers.hh"
GeoNetworkingLayer::GeoNetworkingLayer(const std::string & p_type, const std::string & param) : TLayer<LibItsGeoNetworking__TestSystem::GeoNetworkingPort>(p_type), _codec(), _params() {
loggers::loggers::log(">>> GeoNetworkingLayer::GeoNetworkingLayer: %s, %s", to_string().c_str(), param.c_str());
// Setup parameters
Params::convert(_params, param);
_params.log();
void GeoNetworkingLayer::sendMsg(const LibItsGeoNetworking__TestSystem::GeoNetworkingReq& p, const Params& params) {
loggers::loggers::log(">>> GeoNetworkingLayer::sendMsg");
OCTETSTRING data;
_codec.encode(p.msgOut(), data);
Params par(params);
sendData(data, par);
void GeoNetworkingLayer::sendData(OCTETSTRING& data, Params& params) {
loggers::loggers::log(">>> GeoNetworkingLayer::sendData");
toAllLowerLayers(data, params);
void GeoNetworkingLayer::receiveData(OCTETSTRING& data, Params& info) {
loggers::loggers::log_msg(">>> GeoNetworkingLayer::receiveData: ", data);
// Decode the payload
LibItsGeoNetworking__TestSystem::GeoNetworkingInd p;
_codec.decode(data, p.msgIn());
// Add lower layers parameters
// TODO
// const unsigned char mac_address[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
//data += OCTETSTRING(sizeof(mac_address), static_cast<const unsigned char *>(mac_address));
// Send it to the ports
toAllUpperPorts(p, info);
}
class GeoNetworkingFactory: public LayerFactory {
static GeoNetworkingFactory _f;
public:
GeoNetworkingFactory();
virtual Layer * createLayer(const std::string & type,
const std::string & param);
};
GeoNetworkingFactory::GeoNetworkingFactory() {
// register factory
loggers::loggers::log(">>> GeoNetworkingFactory::GeoNetworkingFactory");
LayerStackBuilder::RegisterLayerFactory("GN", this);
}
Layer * GeoNetworkingFactory::createLayer(const std::string & type, const std::string & param) {
return new GeoNetworkingLayer(type, param);
}
GeoNetworkingFactory GeoNetworkingFactory::_f;