Code APP3

Dependencies:   mbed EthernetInterface WebSocketClient mbed-rtos BufferedSerial

Fork of APP3_Lab by Jean-Philippe Fournier

parser.cpp

Committer:
Cheroukee
Date:
2017-09-30
Revision:
6:9ed8153f1328
Parent:
5:9e6a09a38785
Child:
13:5f21dd134bd2

File content as of revision 6:9ed8153f1328:

#include "parser.h"

unsigned int PanID;
char URL[255] = {0};

LocalFileSystem local("local");

void ReadFile()
{
    Serial pc(USBTX, USBRX); // tx, rx
    FILE *fp = fopen("/local/config.txt", "r");  // Ouvrir config.txt pour lecture seulement
    if(fp == NULL)
    {
        pc.printf("Failed to find configuration file. \n\r");
    }
    else
    {
        pc.printf("Config file opened. \n\r");
        if (fscanf(fp,"0x%x", &PanID) > 0)
        {
            pc.printf("PanId : 0x%x value : %u\r\n", PanID, PanID); // Display PanId
        }
        fscanf(fp,"%s",URL); // read URL        
        pc.printf("ServeurURL : %s\r\n",URL); // Display URL
        fclose(fp);
    }
}