Skip to content

Commit

Permalink
Merge pull request #2 from fredlcore/v0.6
Browse files Browse the repository at this point in the history
V0.6
  • Loading branch information
fredlcore authored Dec 19, 2016
2 parents e2e4127 + 9cfb341 commit 04dc87f
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 55 deletions.
8 changes: 6 additions & 2 deletions BSB_lan/src/BSB_lan.ino → BSB_lan/BSB_lan/BSB_lan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@
* see README file for more information
*
* Version:
* 0.1 - 21.01.2015 - initial version
* 0.1 - 21.01.2015 - initial version
* 0.5 - 02.02.2015
* 0.6 - 02.02.2015
*
* Changelog:
* version 0.6
* - renamed SoftwareSerial to BSBSoftwareSerial
* - changed folder structure to enable simple build with arduino sdk
* version 0.5
* - bugfixes
* - added documentation (README)
Expand All @@ -30,7 +34,7 @@
*/

#include <avr/pgmspace.h>
#include "SoftwareSerial.h"
#include "BSBSoftwareSerial.h"
#include "bsb.h"

#include <SPI.h>
Expand Down
34 changes: 28 additions & 6 deletions BSB_lan/README → BSB_lan/BSB_lan/README
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ Target System:
Missing command ids have to be added in the cmdtbl.
Until now it is not clear to me, what the differences between the LPB and BSB protocols are. The physical specifications
are the same. But may be they differe on the protocol level. Until now I have only connected the system to the BSB.

Software:
The software is intended to be build with the command line tool ino. If you want to use the arduino sdk you may have to change the
folder structure.


BEFORE BUILDING the software you have to adapt some parameters in BSB_lan.ino:
- MAC address of your ethernet shield. It can be normally found on a label at the shield:
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xEA };
Expand All @@ -50,7 +46,9 @@ BEFORE BUILDING the software you have to adapt some parameters in BSB_lan.ino:
BSB bus(68,69);
- (optional) Activate the usage of the passkey functionality (see below)
#define USE_PASSKEY 1

- (optional) BSB address (default is 0x06=RGT1, but can be overwritten in the bus initialization)
BSB bus(68,69,<my_addr>);

Interface:
A simple syntax description is content of the website displayed when the server is accessed by its simple URL withou any parameters.
e.g. http://<ip-of-server>
Expand Down Expand Up @@ -127,3 +125,27 @@ Open issues
- Decode DE telegrams. Maybe they contain some status information and we can use them without querying.

- Add support of error messages send by the boiler system



Extension: TODO

Room temperature sensor simulation:

affected parameters
- 710 - HK1 - Komfortsollwert
- 750 - HK1 - Raumeinfluss
- 700 - HK1 - Betriebsart (0=Schutzbetrieb, 1=Automatik, 2=Reduziert, 3=Komfort)
- INF 10000=Raumtemperatur
- 8740 Diagnose Verbraucher - Raumtemperatur 1
- 8741 Diagnose Verbraucher - Raumsollwert 1

To simulate a room temperature sensor the temperature has to be sent in a regular interval (<10min).
Additionally the boiler can be switched off, when no heating is requested.
When using the PID20 module from fhem, we can try the following approach:
- loop over all PID20 devices
- skip all devices which are not the state processing
- skip all devices with an actuation less than 10 percent
- get the max desired temperature for all not skipped devices
- get the greatest difference from desired and measured temperature for all not skipped devices
- calculate a virtual min measured temperature using this difference
File renamed without changes.
11 changes: 0 additions & 11 deletions BSB_lan/ino.ini

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The latest version of this library can always be found at
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "Arduino.h"
#include "SoftwareSerial.h"
#include "BSBSoftwareSerial.h"
//
// Lookup table
//
Expand Down Expand Up @@ -122,17 +122,17 @@ const int XMIT_START_ADJUSTMENT = 6;

#else

#error This version of SoftwareSerial supports only 20, 16 and 8MHz processors
#error This version of BSBSoftwareSerial supports only 20, 16 and 8MHz processors

#endif

//
// Statics
//
SoftwareSerial *SoftwareSerial::active_object = 0;
char SoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF];
volatile uint8_t SoftwareSerial::_receive_buffer_tail = 0;
volatile uint8_t SoftwareSerial::_receive_buffer_head = 0;
BSBSoftwareSerial *BSBSoftwareSerial::active_object = 0;
char BSBSoftwareSerial::_receive_buffer[_SS_MAX_RX_BUFF];
volatile uint8_t BSBSoftwareSerial::_receive_buffer_tail = 0;
volatile uint8_t BSBSoftwareSerial::_receive_buffer_head = 0;

//
// Debugging
Expand All @@ -158,7 +158,7 @@ inline void DebugPulse(uint8_t pin, uint8_t count)
//

/* static */
inline void SoftwareSerial::tunedDelay(uint16_t delay) {
inline void BSBSoftwareSerial::tunedDelay(uint16_t delay) {
uint8_t tmp=0;

asm volatile("sbiw %0, 0x01 \n\t"
Expand All @@ -173,7 +173,7 @@ inline void SoftwareSerial::tunedDelay(uint16_t delay) {

// This function sets the current object as the "listening"
// one and returns true if it replaces another
bool SoftwareSerial::listen()
bool BSBSoftwareSerial::listen()
{
if (active_object != this)
{
Expand All @@ -192,7 +192,7 @@ bool SoftwareSerial::listen()
//
// The receive routine called by the interrupt handler
//
void SoftwareSerial::recv()
void BSBSoftwareSerial::recv()
{

#if GCC_VERSION < 40302
Expand Down Expand Up @@ -272,15 +272,15 @@ void SoftwareSerial::recv()
#endif
}

void SoftwareSerial::tx_pin_write(uint8_t pin_state)
void BSBSoftwareSerial::tx_pin_write(uint8_t pin_state)
{
if (pin_state == LOW)
*_transmitPortRegister &= ~_transmitBitMask;
else
*_transmitPortRegister |= _transmitBitMask;
}

uint8_t SoftwareSerial::rx_pin_read()
uint8_t BSBSoftwareSerial::rx_pin_read()
{
return *_receivePortRegister & _receiveBitMask;
}
Expand All @@ -290,7 +290,7 @@ uint8_t SoftwareSerial::rx_pin_read()
//

/* static */
inline void SoftwareSerial::handle_interrupt()
inline void BSBSoftwareSerial::handle_interrupt()
{
if (active_object)
{
Expand All @@ -301,35 +301,35 @@ inline void SoftwareSerial::handle_interrupt()
#if defined(PCINT0_vect)
ISR(PCINT0_vect)
{
SoftwareSerial::handle_interrupt();
BSBSoftwareSerial::handle_interrupt();
}
#endif

#if defined(PCINT1_vect)
ISR(PCINT1_vect)
{
SoftwareSerial::handle_interrupt();
BSBSoftwareSerial::handle_interrupt();
}
#endif

#if defined(PCINT2_vect)
ISR(PCINT2_vect)
{
SoftwareSerial::handle_interrupt();
BSBSoftwareSerial::handle_interrupt();
}
#endif

#if defined(PCINT3_vect)
ISR(PCINT3_vect)
{
SoftwareSerial::handle_interrupt();
BSBSoftwareSerial::handle_interrupt();
}
#endif

//
// Constructor
//
SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) :
BSBSoftwareSerial::BSBSoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic /* = false */) :
_rx_delay_centering(0),
_rx_delay_intrabit(0),
_rx_delay_stopbit(0),
Expand All @@ -344,12 +344,12 @@ SoftwareSerial::SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inv
//
// Destructor
//
SoftwareSerial::~SoftwareSerial()
BSBSoftwareSerial::~BSBSoftwareSerial()
{
end();
}

void SoftwareSerial::setTX(uint8_t tx)
void BSBSoftwareSerial::setTX(uint8_t tx)
{
pinMode(tx, OUTPUT);
digitalWrite(tx, LOW);
Expand All @@ -358,7 +358,7 @@ void SoftwareSerial::setTX(uint8_t tx)
_transmitPortRegister = portOutputRegister(port);
}

void SoftwareSerial::setRX(uint8_t rx)
void BSBSoftwareSerial::setRX(uint8_t rx)
{
pinMode(rx, INPUT);
if (!_inverse_logic)
Expand All @@ -373,7 +373,7 @@ void SoftwareSerial::setRX(uint8_t rx)
// Public methods
//

void SoftwareSerial::begin(long speed)
void BSBSoftwareSerial::begin(long speed)
{
_rx_delay_centering = _rx_delay_intrabit = _rx_delay_stopbit = _tx_delay = 0;

Expand Down Expand Up @@ -409,15 +409,15 @@ void SoftwareSerial::begin(long speed)
listen();
}

void SoftwareSerial::end()
void BSBSoftwareSerial::end()
{
if (digitalPinToPCMSK(_receivePin))
*digitalPinToPCMSK(_receivePin) &= ~_BV(digitalPinToPCMSKbit(_receivePin));
}


// Read data from buffer
int SoftwareSerial::read()
int BSBSoftwareSerial::read()
{
if (!isListening())
return -1;
Expand All @@ -432,15 +432,15 @@ int SoftwareSerial::read()
return d;
}

int SoftwareSerial::available()
int BSBSoftwareSerial::available()
{
if (!isListening())
return 0;

return (_receive_buffer_tail + _SS_MAX_RX_BUFF - _receive_buffer_head) % _SS_MAX_RX_BUFF;
}

size_t SoftwareSerial::write(byte b)
size_t BSBSoftwareSerial::write(byte b)
{
if (_tx_delay == 0) {
setWriteError();
Expand Down Expand Up @@ -487,7 +487,7 @@ size_t SoftwareSerial::write(byte b)
return 1;
}

void SoftwareSerial::flush()
void BSBSoftwareSerial::flush()
{
if (!isListening())
return;
Expand All @@ -498,7 +498,7 @@ void SoftwareSerial::flush()
SREG = oldSREG;
}

int SoftwareSerial::peek()
int BSBSoftwareSerial::peek()
{
if (!isListening())
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ The latest version of this library can always be found at
http://arduiniana.org.
*/

#ifndef SoftwareSerial_h
#define SoftwareSerial_h
#ifndef BSBSoftwareSerial_h
#define BSBSoftwareSerial_h

#include <inttypes.h>
#include <Stream.h>
Expand All @@ -51,7 +51,7 @@ The latest version of this library can always be found at
#define GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif

class SoftwareSerial : public Stream
class BSBSoftwareSerial : public Stream
{
private:
// per object data
Expand All @@ -73,7 +73,7 @@ class SoftwareSerial : public Stream
static char _receive_buffer[_SS_MAX_RX_BUFF];
static volatile uint8_t _receive_buffer_tail;
static volatile uint8_t _receive_buffer_head;
static SoftwareSerial *active_object;
static BSBSoftwareSerial *active_object;

// private methods
void recv();
Expand All @@ -86,8 +86,8 @@ class SoftwareSerial : public Stream

public:
// public methods
SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false);
~SoftwareSerial();
BSBSoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false);
~BSBSoftwareSerial();
void begin(long speed);
bool listen();
void end();
Expand Down
2 changes: 1 addition & 1 deletion BSB_lan/lib/BSB/bsb.cpp → BSB_lan/libraries/BSB/bsb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

// Constructor
BSB::BSB(uint8_t rx, uint8_t tx, uint8_t addr) {
serial = new SoftwareSerial(rx, tx, true);
serial = new BSBSoftwareSerial(rx, tx, true);

serial->begin(4800);
serial->listen();
Expand Down
4 changes: 2 additions & 2 deletions BSB_lan/lib/BSB/bsb.h → BSB_lan/libraries/BSB/bsb.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "WProgram.h"
#endif

#include "SoftwareSerial.h"
#include "BSBSoftwareSerial.h"
#include "util/crc16.h"

// See this page for further details:
Expand Down Expand Up @@ -48,7 +48,7 @@ class BSB
inline void _send(byte* msg);
uint16_t CRC (byte* buffer, uint8_t length);

SoftwareSerial* serial;
BSBSoftwareSerial* serial;
};

#endif
File renamed without changes.

0 comments on commit 04dc87f

Please sign in to comment.