mbed Phone Platform

Dependencies:   ulaw mbed ConfigFile

IpLine.h

Committer:
okini3939
Date:
2011-01-07
Revision:
4:41a3534d085f
Parent:
3:1d5dc4107558
Child:
5:30e2847d241b

File content as of revision 4:41a3534d085f:

#include "phone.h"
#include "mbed.h"
#include "EthernetNetIf.h"
#include "UDPSocket.h"
#include "RingBuffer.h"
#include "ulaw.h"

struct ipline_header {
    unsigned long ident;
    unsigned short num;
    enum PhoneType target;
    enum Mode mode;
    enum Status status;
};

struct ipline_packet {
    struct ipline_header header;
    unsigned short len;
    char data[DATA_SIZE];
};


/**
 * @brief IpLine class
 */
class IpLine {
public:
    IpLine (AnalogOut, AnalogIn);

    void intr ();
    void poll ();
    int enter (enum Mode);
    int scan (enum Scan);
    void settarget (enum PhoneType, char *);

private:
    enum PhoneType remotetarget;
    enum Mode mode;
    enum Status status;
    int hook, packet_num, dataskip, timeout, dialconut;
    EthernetNetIf *eth;
    UDPSocket *udpsock;
    Host remote;
    AnalogOut dac;
    AnalogIn adc;
    RingBuffer dial, dabuf, adbuf;
    struct ipline_header last;
    DigitalOut led1, led2, led3, led4;

    void onLisnerEvent (UDPSocketEvent);
    void send (struct ipline_header *);
    void send (struct ipline_packet *);
    unsigned long xor128 ();
    int gaussian ();
};