mbusSlaveRegister (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

LX4,NX-400

Firmware version:

1.94.00


This function registers a slave device.

Registered device can be decrypted if the correct key is provided.

Only data from registered devices is received if the receive filter is enabled with mbusFilterEnable.

The registration is persistent and must be removed with mbusSlaveUnregister.

 

Input:

handle : SYSHANDLE

A handle to the connection

 

index : USINT (1..64)

The index of the registration.

 

sec_addr : STRING

The address to the slave to register. See mbusScan for a description of the address format.

 

key : PTR

Pointer to a 16-byte array containing the key needed to decrypt the data.

 

 

Returns: INT

1

- Success.

0

- Not supported.

-1

- Invalid handle

-2

- Index out of range.

-5

- Invalid interface type.

-6

- Invalid address.

-9

- Communication error

 

Declaration:

FUNCTION mbusSlaveRegister : INT;
VAR_INPUT
  handle   : SYSHANDLE;
  key      : PTR;
  sec_addr : STRING;
  index    : USINT;
END_VAR;

 

 

Example:

 
FUNCTION RegisterDevices;
VAR
  rc  : INT;
  key : ARRAY[1..16] OF USINT;
END_VAR;
 
  // wM-Bus Meter with integrated radio and Security profile B from OMS specification Annex N.2.3.
  key[1] := 16#00;
  key[2] := 16#01;
  key[3] := 16#02;
  key[4] := 16#03;
  key[5] := 16#04;
  key[6] := 16#05;
  key[7] := 16#06;
  key[8] := 16#07;
  key[9] := 16#08;
  key[10] := 16#09;
  key[11] := 16#0a;
  key[12] := 16#0b;
  key[13] := 16#0c;
  key[14] := 16#0d;
  key[15] := 16#0e;
  key[16] := 16#0f;
 
  rc := mbusSlaveRegister(handle:=mb, sec_addr:="1234567893153303", index:=1, key:=ADDR(key));
  DebugFmt(message:="mbusSlaveRegister(): \1", v1:=rc);
END_FUNCTION;