UniSaSA  1.0
Embedded Library
Data Structures | Macros | Typedefs | Functions
unisasa.h File Reference
#include "unisasa_types.h"

Go to the source code of this file.

Data Structures

union  converter_t
 
union  deviceAddress_t
 
struct  device_t
 
union  sensorType_t
 
struct  sensor_t
 
union  actuatorType_t
 
struct  actuator_t
 

Macros

#define NUMSENS   64
 
#define NUMACTS   64
 
#define FIRST_ID_SEN   0
 
#define FIRST_ID_ACT   0
 
#define BYTES_ADDRESS_DEVICE   1
 
#define ADDR_ANY   0
 
#define BYTES_UNSIGNED_INT   4 /** for ID_t */
 
#define BYTES_MESSAGE   8 /** MAX could be 255, see mcu memory */
 
#define LITTLE_ENDIAN
 
#define SEND(array, size, converter)   _reverseArray(array, size, converter); send(converter, size)
 
#define RECV(array, size, converter)   receive(converter, size); _reverseArray(converter, size, array)
 

Typedefs

typedef unsigned char byte_t
 
typedef union converter_t converter_t
 
typedef union deviceAddress_t deviceAddress_t
 
typedef void(* messageHandlerFunc) (unsigned char *)
 
typedef void(* messageAndAnswerHandlerFunc) (unsigned char *request, unsigned char *reply)
 
typedef struct device_t device_t
 
typedef void(* getSensorValueFunc) (unsigned char *sensor_value)
 
typedef union sensorType_t sensorType_t
 
typedef struct sensor_t sensor_t
 
typedef void(* setActuatorValueFunc) (unsigned char *act_value)
 
typedef union actuatorType_t actuatorType_t
 
typedef struct actuator_t actuator_t
 
typedef void(* receiveUnisasa) (unsigned char *message, unsigned int size)
 
typedef void(* sendUnisasa) (unsigned char *message, unsigned int size)
 

Functions

void createDevice (unsigned int address, unsigned char sizeIOmsg, messageHandlerFunc callback1, messageAndAnswerHandlerFunc callback2)
 
void addSensor (unsigned int typeSensor, unsigned char sizeOutput, unsigned char typeOutput, getSensorValueFunc getValue)
 
void addActuator (unsigned int typeActuator, unsigned char sizeInput, unsigned char typeInput, setActuatorValueFunc setValue)
 
void communication (receiveUnisasa recvFunc, sendUnisasa sendFunc)
 

Detailed Description

Unisasa header file for microcontrollers. Use this API to interface your MCUs with UniSaSA easily and quickly

Definition in file unisasa.h.

Typedef Documentation

◆ actuator_t

typedef struct actuator_t actuator_t

Internal use only use addActuator

See also
addActuator

◆ actuatorType_t

Internal use only

◆ converter_t

typedef union converter_t converter_t

Converter unsigned int/ unsigned char iternal use only.

◆ device_t

typedef struct device_t device_t

Internal use only use createDevice()

See also
createDevice()

◆ deviceAddress_t

Address Device Internal use only fast convert int/char*

◆ getSensorValueFunc

typedef void(* getSensorValueFunc) (unsigned char *sensor_value)

callback function called when a gateway wants to get the value from the sensor

Parameters
valuea byte array, size and type definited in addSensor

Definition at line 154 of file unisasa.h.

◆ messageAndAnswerHandlerFunc

typedef void(* messageAndAnswerHandlerFunc) (unsigned char *request, unsigned char *reply)

callback function called when a gateway send a message and wants a reply

Parameters
requestreceived from the gateway
replyto send to the gateway
See also
createDevice()

Definition at line 118 of file unisasa.h.

◆ messageHandlerFunc

typedef void(* messageHandlerFunc) (unsigned char *)

callback function called when a gateway send a message

Parameters
messagereceived from the gateway
See also
createDevice()

Definition at line 109 of file unisasa.h.

◆ receiveUnisasa

typedef void(* receiveUnisasa) (unsigned char *message, unsigned int size)

receive function The implementation depends on your communication medium

Parameters
buffermessage
sizeread size bytes
See also
startCommunication()

Definition at line 245 of file unisasa.h.

◆ sendUnisasa

typedef void(* sendUnisasa) (unsigned char *message, unsigned int size)

send function The implementation depends on your communication medium

Parameters
messagein bytes to send
sizeMessagesize of the previous param
See also
startCommunication()

Definition at line 254 of file unisasa.h.

◆ sensor_t

typedef struct sensor_t sensor_t

Internal use only use addSensor()

See also
addSesor()

◆ sensorType_t

typedef union sensorType_t sensorType_t

Internal use only

◆ setActuatorValueFunc

typedef void(* setActuatorValueFunc) (unsigned char *act_value)

callback function called when a gateway wants to set the value of the actuator

Parameters
valuea byte array, size and type definited in addActuator

Definition at line 198 of file unisasa.h.

Function Documentation

◆ addActuator()

void addActuator ( unsigned int  typeActuator,
unsigned char  sizeInput,
unsigned char  typeInput,
setActuatorValueFunc  setValue 
)

Add an actuator create a new internal actuator structure, dont use it directly

Parameters
typeActuatorconstant defined in Actuator type
sizeInputsize actuator input in byte
typeInputconstant defined in Sensor/Actuators IO type
setValuecallback function (for SET_ACUATOR_VALUE message)

Definition at line 75 of file unisasa.c.

◆ addSensor()

void addSensor ( unsigned int  typeSensor,
unsigned char  sizeOutput,
unsigned char  typeOutput,
getSensorValueFunc  getValue 
)

Add a sensor create a new internal sensor structure, dont use it directly

Parameters
typeSensorconstant defined in Sensor type
sizeOutputsize sensor output in byte
typeOutputconstant defined in Sensor/Actuators IO type
getValuecallback function (for GET_SENSOR_VALUE message)

Definition at line 64 of file unisasa.c.

◆ communication()

void communication ( receiveUnisasa  recvFunc,
sendUnisasa  sendFunc 
)

Manage communication with the gateway Active the communication loop, it is blocking

Parameters
receiveFuncyour communication device receive function
sendFuncyour communication device send function
See also
recvUnisasa
sendUnisasa

Definition at line 87 of file unisasa.c.

◆ createDevice()

void createDevice ( unsigned int  address,
unsigned char  sizeIOmsg,
messageHandlerFunc  callback1,
messageAndAnswerHandlerFunc  callback2 
)

Setup this device Function to setup the hardware device/node/mcu

Parameters
addressdepends on your device, it could be unconcerned
sizeIOmsg(byte) request/replay to/from this device function, the callback for the 'MSG_TO_DEVICE' message function, the callback for the 'MSG_TO_DEVICE_AND_ANSWER' message

Definition at line 54 of file unisasa.c.