Radiocraft Wireless M-Bus extension module  1.00.00
Implementation C functions

These functions are called directly from the Modcall C functions. More...

Functions

static int mbusClose (void)
 Closes the communication interface. More...
 
static int mbusOpen (int8 mode, int8 rssi)
 Opens the connection to the M-Bus module. More...
 
static int mbusSend (int16 c, int8 *data, int8 size)
 Send an M-BUS packet. More...
 
static int mbusReceive (tdef_mbus_start_frame *start, int8 *data, int16 *rssi)
 Receive a new frame from the M-Bus module. More...
 
static int mbus_register_slave (int idx, int16 manufacturer, int32 id, int8 version, int8 type, uint8 *key)
 Registers/installs a slave device on the M-Bus module. More...
 
static int mbus_info (void)
 Print some information about the RF module to the device output. More...
 

Detailed Description

These functions are called directly from the Modcall C functions.

Function Documentation

◆ mbus_info()

static int mbus_info ( void  )
static

Print some information about the RF module to the device output.

Returns
-1 Communication error.
0 Success.

Definition at line 1272 of file mod_mbus.c.

References mbus_read_regs(), mbusConfigCmd(), mbusConfigEnter(), mbusConfigExit(), and mbusDebug().

Referenced by mbusCallInfo().

◆ mbus_register_slave()

static int mbus_register_slave ( int  idx,
int16  manufacturer,
int32  id,
int8  version,
int8  type,
uint8 *  key 
)
static

Registers/installs a slave device on the M-Bus module.

This is necessary when filtering or when using encryption.

Parameters
[in]idxThe index of the slave to register. 1-64.
[in]manufacturerThe ID of the manufacturer. Part of the device address.
[in]idThe device identification number/serial number. Part of the device address.
[in]versionThe device version. Part of the device address.
[in]typeThe device type. Part of the device address.
[in]keyThe 16 byte (128 bit) encryption key. Can be set to NULL if encryption is not used.
Returns
-2 Invalid idx
-1 communication error
0 Slave was registered

Definition at line 1222 of file mod_mbus.c.

References mbusConfigCmd(), mbusConfigEnter(), mbusConfigExit(), and mbusConfigTransact().

Referenced by mbusCallRegisterSlave().

◆ mbusClose()

static int mbusClose ( void  )
static

Closes the communication interface.

Returns
0 success
-1 failed to close interface

Definition at line 884 of file mod_mbus.c.

References fd, mbusDebug(), and mbusPower().

Referenced by mbusCallClose(), mbusCallInfo(), and moduleNotify().

◆ mbusOpen()

static int mbusOpen ( int8  mode,
int8  rssi 
)
static

Opens the connection to the M-Bus module.

This must be called before the rest of the functions will work.

Parameters
[in]modeThe M-Bus mode to use.
  • 0 = S2
  • 1 = T1 (default)
  • 2 = T2
  • 3 = S1
  • 4 = R
  • 10 = T1+C
  • 11 = T2+C
[in]rssiSet to true to include the signal strength (RSSI) for each valid packet. It can be read from mbusReceive() and is available in the mbusFrame struct block (mbus_frame).
Returns
0 success
-1 failed to open interface

Definition at line 919 of file mod_mbus.c.

References fd, mbus_config(), mbusConfigEnter(), mbusConfigExit(), mbusDebug(), and mbusPower().

Referenced by mbusCallInfo(), and mbusCallOpen().

◆ mbusReceive()

static int mbusReceive ( tdef_mbus_start_frame start,
int8 *  data,
int16 *  rssi 
)
static

Receive a new frame from the M-Bus module.

Parameters
[in]startThe frame to store the information from the header in.
[in]dataBuffer to store the received data in.
[out]rssiIf not NULL and if the RSSI is included in the packet, this is set to the RSSI of the packet.
Returns
-1 communication error
0 no data
1 data received

Definition at line 1105 of file mod_mbus.c.

References fd, mbus_start_frame::length, MBUS_DATA_LENGTH, mbusDebug(), and rssi_included.

Referenced by mbusCallReceive().

◆ mbusSend()

static int mbusSend ( int16  c,
int8 *  data,
int8  size 
)
static

Send an M-BUS packet.

This will send a M-BUS message, if c is not -1 then the control field will be changed before sending. If no length is supplied then only the header frame will be send.

Parameters
[in]cNew value for the Control field if not -1.
[in]dataData to send, may be null if only header is to be send.
[in]sizeSize of data to send, if 0 the only header will be send
Returns
-1 communication error
0 success

Definition at line 1020 of file mod_mbus.c.

References fd, mbusConfigCmd(), mbusConfigEnter(), mbusConfigExit(), and mbusDebug().

Referenced by mbusCallSend().