Richard Nash / xpl

Dependents:   XPL-App4_cleanup XPL-App5

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers xPL_utils.h Source File

xPL_utils.h

00001 /*
00002  * xPL.Arduino v0.1, xPL Implementation for Arduino
00003  *
00004  * This code is parsing a xPL message stored in 'received' buffer
00005  * - isolate and store in 'line' buffer each part of the message -> detection of EOL character (DEC 10)
00006  * - analyse 'line', function of its number and store information in xpl_header memory
00007  * - check for each step if the message respect xPL protocol
00008  * - parse each command line
00009  *
00010  * Copyright (C) 2012 johan@pirlouit.ch, olivier.lebrun@gmail.com
00011  * Original version by Gromain59@gmail.com
00012  *
00013  * This program is free software; you can redistribute it and/or
00014  * modify it under the terms of the GNU General Public License
00015  * as published by the Free Software Foundation; either version 2
00016  * of the License, or (at your option) any later version.
00017  *
00018  * This program is distributed in the hope that it will be useful,
00019  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00020  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00021  * GNU General Public License for more details.
00022  *
00023  * You should have received a copy of the GNU General Public License
00024  * along with this program; if not, write to the Free Software
00025  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00026 */
00027  
00028 #ifndef xPLutil_h
00029 #define xPLutil_h
00030 
00031 //#include "Arduino.h"
00032 #include "mbed.h"
00033 #include <string.h>
00034 
00035 #define XPL_VENDOR_ID_MAX       8
00036 #define XPL_DEVICE_ID_MAX       20
00037 #define XPL_INSTANCE_ID_MAX     16
00038 #define XPL_CLASS_ID_MAX        8
00039 #define XPL_TYPE_ID_MAX         8
00040 #define XPL_NAME_LENGTH_MAX     20
00041 #define XPL_VALUE_LENGTH_MAX    128  // should be 128 but need to spare RAM
00042 
00043 #define XPL_HOP_COUNT_PARSER    "hop=%d"
00044 #define XPL_SOURCE_PARSER       "source=%20[^-]-%20[^'.'].%16s"
00045 #define XPL_TARGET_PARSER       "target=%20[^-]-%20[^'.'].%16s"
00046 #define XPL_SCHEMA_PARSER       "%8[^'.'].%8s"
00047 // 32 shall match XPL_VALUE_LENGTH_MAX
00048 #define XPL_COMMAND_PARSER      "%20[^'=']=%32s"
00049 
00050 typedef struct struct_id struct_id;
00051 struct struct_id            // source or target
00052 {
00053     char vendor_id[XPL_VENDOR_ID_MAX+1];        // vendor id
00054     char device_id[XPL_DEVICE_ID_MAX+1];        // device id
00055     char instance_id[XPL_INSTANCE_ID_MAX+1];        // instance id
00056 };
00057 
00058 typedef struct struct_xpl_schema struct_xpl_schema;
00059 struct struct_xpl_schema
00060 {
00061     char class_id[XPL_CLASS_ID_MAX+1];  // class of schema (x10, alarm...)
00062     char type_id[XPL_TYPE_ID_MAX+1];    // type of schema (basic...)
00063 };
00064 
00065 typedef struct struct_command struct_command;
00066 struct struct_command           // source or target
00067 {
00068     char name[XPL_NAME_LENGTH_MAX+1];       // vendor id
00069     char value[XPL_VALUE_LENGTH_MAX+1];     // device id
00070 };
00071 
00072 void clearStr (char* str);
00073 
00074 #endif