
Auto connect object is used to define how the meter will make a connection to the server.
This feature can be used with dynamic IP addresses when the meter IP address is unknown. The meter will establish the connection with a given interval to the reader service so the reader can read the meter when needed.
Properties
-
1. Logical Name
Logical name of the object.
-
2. Mode
Defines how device is making connection to the server.
-
3. Repetitions
How many times is try to connect to the server.
-
4. Repetition delay
How many seconds is waited before reconnect.
-
5. Calling window
Time window when device try to make connection to the server.
-
6. Destination list
Contains list of phone numbers, TCP/IP address, etc where connection is made.
Actions
There are no actions available for this object type.
gxByteBuffer *str;
gxtime *start, *end;
const unsigned char ln[6] = { 0,0,2,1,0,255 };
cosem_init2((gxObject*)&autoConnect, DLMS_OBJECT_TYPE_AUTO_CONNECT, ln);
autoConnect.mode = DLMS_AUTO_CONNECT_MODE_AUTO_DIALLING_ALLOWED_ANYTIME;
autoConnect.repetitions = 10;
autoConnect.repetitionDelay = 60;
//Calling is allowed between 1am to 6am.
start = (gxtime*)malloc(sizeof(gxtime));
time_init3(start, -1, -1, -1, 1, 0, 0, -1);
end = (gxtime*)malloc(sizeof(gxtime));
time_init3(end, -1, -1, -1, 6, 0, 0, -1);
arr_push(&autoConnect.callingWindow, key_init(start, end));
//Add destination.
str = (gxByteBuffer*)malloc(sizeof(gxByteBuffer));
bb_init(str);
bb_addString(str, "www.gurux.org");
arr_push(&autoConnect.destinations, str);
//How to loop through all calling window items.
gxKey* k;
int pos, ret;
for (pos = 0; pos != object->callingWindow.size; ++pos)
{
if (pos != 0)
{
bb_addString(&ba, ", ");
}
ret = arr_getByIndex(&object->callingWindow, pos, (void**)&k);
if (ret != 0)
{
return ret;
}
time_print("From: %s", (gxtime*)k->key);
time_print(" to:%s\r\n", (gxtime*)k->value);
}
//How to loop through all destinations.
int pos, ret;
gxByteBuffer *dest;
for (pos = 0; pos != object->destinations.size; ++pos)
{
ret = arr_getByIndex(&object->destinations, pos, (void**)&dest);
if (ret != 0)
{
return ret;
}
}