lib/mbselib.h

Sun, 04 May 2014 17:18:27 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 04 May 2014 17:18:27 +0200
changeset 20
f7f9463cdefd
parent 18
3f4823083b9d
child 22
a3b058c67289
permissions
-rw-r--r--

Added 433 MHz transmitter and receiver library and demo programs

#ifndef	_MBSELIB_H
#define	_MBSELIB_H

#include "../config.h"

#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <syslog.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <getopt.h>

/* mosquitto */
#include <mosquitto.h>

#ifdef HAVE_WIRINGPI_H
/* wiringPi */
#include <wiringPi.h>
#include <pcf8574.h>
#include <lcd.h>

#endif

#define TRUE 1
#define FALSE 0

#define MBSE_SS(x) (x)?(x):"(null)"

/* rdconfig.c */
typedef struct _key_list {
    char	*key;
    int		(*prc)(char **);
    char	**dest;
} key_list;

typedef struct _w1_therm {
    struct _w1_therm    *next;
    char                *master;                /* Master for this device       */
    int                 bus;                    /* Reserved for ds2482-800      */
    char                *name;                  /* Name of this device          */
    char                *alias;                 /* Friendly name                */
    int                 present;                /* 1=present, 0=absent          */
    int                 lastval;                /* Last valid value             */
} w1_therm;

typedef struct _sys_config {
    char		*name;			/* Configuration name		*/
    char		*mosq_host;		/* mosquitto server hostname	*/
    int			mosq_port;		/* mosquitto server port	*/
    w1_therm		*w1therms;		/* 1-wire temp sensors		*/
#ifdef HAVE_WIRINGPI_H
    int			lcd_cols;		/* LCD display columns		*/
    int			lcd_rows;		/* LCD display rows		*/
#endif
} sys_config;



void killconfig(void);
int  rdconfig(void);


/* xutil.c */
char *xmalloc(size_t);
char *xstrcpy(char *);
char *xstrcat(char *, char *);


#ifdef HAVE_WIRINGPI_H

/* lcd-pcf8574.c */
// Defines for the pcf8574 Pi LCD interface board
#define AF_BASE         100

#define AF_RS           (AF_BASE + 0)
#define AF_RW           (AF_BASE + 1)
#define AF_E            (AF_BASE + 2)
#define AF_BACKLIGHT    (AF_BASE + 3)
#define AF_DB4          (AF_BASE + 4)
#define AF_DB5          (AF_BASE + 5)
#define AF_DB6          (AF_BASE + 6)
#define AF_DB7          (AF_BASE + 7)

void setBacklight (int);
int  initLCD (int, int);



/* rc-switch.c */
#define CHANGE 1

//typedef uint8_t boolean;
//typedef uint8_t byte;

// Number of maximum High/Low changes per packet.
// We can handle up to (unsigned long) => 32 bit * 2 H/L changes per bit + 2 for sync
#define RCSWITCH_MAX_CHANGES 67

#define PROTOCOL3_SYNC_FACTOR   71
#define PROTOCOL3_0_HIGH_CYCLES  4
#define PROTOCOL3_0_LOW_CYCLES  11
#define PROTOCOL3_1_HIGH_CYCLES  9
#define PROTOCOL3_1_LOW_CYCLES   6


void switchOn(int, int);
void switchOff(int, int);
/*
void switchOn(char* sGroup, int nSwitchNumber);
void switchOff(char* sGroup, int nSwitchNumber);
void switchOn(char sFamily, int nGroup, int nDevice);
void switchOff(char sFamily, int nGroup, int nDevice);
void switchOn(char* sGroup, char* sDevice);
void switchOff(char* sGroup, char* sDevice);
void switchOn(char sGroup, int nDevice);
void switchOff(char sGroup, int nDevice);
*/
//void sendTriState(char* Code);
//void send(unsigned long Code, unsigned int length);
//void send(char* Code);

void enableReceiveIRQ(int interrupt);
void enableReceive(void);
void disableReceive(void);
bool available(void);
void resetAvailable(void);

unsigned long getReceivedValue(void);
unsigned int getReceivedBitlength(void);
unsigned int getReceivedDelay(void);
unsigned int getReceivedProtocol(void);
unsigned int *getReceivedRawdata(void);

void enableTransmit(int);
void disableTransmit(void);
void setPulseLength(int);
void setRepeatTransmit(int);
void setReceiveTolerance(int);
void setProtocol(int);
//void setProtocol(int nProtocol, int nPulseLength);


#endif


#endif

mercurial