Code APP3

Dependencies:   mbed EthernetInterface WebSocketClient mbed-rtos BufferedSerial

Fork of APP3_Lab by Jean-Philippe Fournier

main.cpp

Committer:
Cheroukee
Date:
2017-09-30
Revision:
11:ecf5776b950a
Parent:
9:3631d3685cfa
Child:
12:1286b80c68f7

File content as of revision 11:ecf5776b950a:

#include "mbed.h"

#include "xbee.h"
#include "parser.h"
#include "sensors.h"

#define IS_COORDINATOR 1

#define PAN_ID 0xC0FFEE

Serial pc(USBTX, USBRX); // tx, rx

char recv_buff[2048] = {0};

int main() {

    ReadFile();

    xbee_init();

    char c;

    char hello_world[12] = "Hello world";

    frame_t current_frame;

#if IS_COORDINATOR

#else
    Test();
    DECLARE_ADDR64_COORD
    DECLARE_ADDR16_UNKNOWN_OR_BCAST
    transmit_request(hello_world, 11, 0, USE_ADDR64_COORD, USE_ADDR16_UNKNOWN_OR_BCAST);
#endif

    while(1) {
        bool finished_packet = receive(&current_frame, 2048);

        if (finished_packet)
        {
            pc.printf("Data count = %u\r\n", current_frame.length);
            pc.printf("data start::: ");
            for (int i = 0; i < current_frame.length && i < 2048; i++)
            {
                pc.putc(current_frame.buffer[i]);            
            }
            pc.printf(" :::end\n\r");
        }
        //wait_ms(1);
    }
}