Map27
 All Classes Functions Variables Enumerations Enumerator Pages
test2.cpp

Test program used to exercise the code when connected to a real radio

// test2.cpp
//
// Program for exercising the Map27 protocol with a real radio
// Works with Tait 2040
//
// Author: Mike McCauley (mikem@airspayce.com)
// Copyright (C) 2013 Mike McCauley
// $Id: test2.cpp,v 1.12 2013/07/14 07:15:46 mikem Exp mikem $
#include "Address.h"
#include "PhysicalLayer.h"
#include "DataLayer.h"
#include "NetworkLayer.h"
#include "UnixPort.h"
#include "Log.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#define RADIO_DEVICE_NAME "/dev/ttyUSB0"
#define RADIO_DEVICE_BAUD 9600
class TestNetworkLayer: public Map27NetworkLayer
{
void link_ready()
{
DEBUG_PRINTF("received network link_ready\n");
}
{
DEBUG_PRINTF("received network_layer_packet\n");
// Accept the packet, making room for another in the data layer:
}
};
int main(int argc, char** argv)
{
TestNetworkLayer network;
// Configure the port
port.setDevice(RADIO_DEVICE_NAME);
port.configure(RADIO_DEVICE_BAUD);
// Connect the layers
physical.setPort(&port);
physical.setDataLayer(&data);
data.setPhysicalLayer(&physical);
data.setNetworkLayer(&network);
network.setDataLayer(&data);
network.power_on();
uint8_t count = 0;
while (1)
{
network.poll();
usleep(10000);
Map27Address address;
address.setPrefix(7);
address.setIdent(5996);
uint8_t sst_data[] = { MAP27_NETWORK_MESSAGE_SEND_SST_CODING_OCTETS, 0x11, 0x22, 0x33, 0x44 };
uint8_t modem_data[] = { 0x11, 0x22, 0x33 };
uint8_t dialled_string[] = { '*', '4', '1', '*', '2', '3', '4', '#' }; // Divert Own Calls
if (network.is_idle())
{
// network.sendStatus(address, MAP27_NETWORK_MESSAGE_STATUS_ON_HOOK);
network.sendStatus(address, count++);
// data.network_layer_packet(buf, sizeof(buf));
// network.sendRadioInterrogation(MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_PERSONALITY);
// network.sendRadioInterrogation(MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_NUMBERING);
// network.sendRadioInterrogation(MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_STATUS);
// network.sendRadioInterrogation(MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_OPERATING_CONDITION);
// network.sendRadioInterrogation(MAP27_NETWORK_MESSAGE_RADIO_INTERROGATION_NETWORK_INFORMATION);
// network.sendSST(address, sst_data, sizeof(sst_data));
// network.sendMST(address, sst_data, sizeof(sst_data));
// network.setupVoiceModem(address, MAP27_NETWORK_MESSAGE_SETUP_VOICE_MODEM_DETAILS_MODEM);
// network.setupEmergencyVoiceModem(address, MAP27_NETWORK_MESSAGE_SETUP_VOICE_MODEM_DETAILS_MODEM);
// network.sendModemData(modem_data, sizeof(modem_data));
// network.sendVolumeControl(MAP27_NETWORK_MESSAGE_VOLUME_CONTROL_POINT_ALERTS, MAP27_NETWORK_MESSAGE_VOLUME_SET_UP);
// network.sendDialledString(dialled_string, sizeof(dialled_string));
// network.sendRadioTest(dialled_string, sizeof(dialled_string));
}
}
return 0;
}