first use of libmbus
This commit is contained in:
parent
b1e2277ef5
commit
c2efa9d8f3
@ -17,6 +17,8 @@ typedef struct {
|
||||
char deviceName[MBUSDEVICE_NAMELENGTH];
|
||||
uint8_t address;
|
||||
t_mbusFrameField consideredField[MBUSDEVICE_NUM_OF_CONSIDEREDFIELDS];
|
||||
uint32_t requests;
|
||||
uint32_t failures;
|
||||
} t_mbusDevice;
|
||||
|
||||
|
||||
|
@ -35,7 +35,9 @@ static t_mbusDevice devices[] = {
|
||||
{ .label = "power", .index = 17 },
|
||||
{ .label = "", .index = 0 },
|
||||
{ .label = "", .index = 0 }
|
||||
}
|
||||
},
|
||||
.requests = 0,
|
||||
.failures = 0
|
||||
},
|
||||
{
|
||||
.deviceName = "Computer Power",
|
||||
@ -45,7 +47,9 @@ static t_mbusDevice devices[] = {
|
||||
{ .label = "power", .index = 4 },
|
||||
{ .label = "voltage", .index = 2 },
|
||||
{ .label = "current", .index = 3 }
|
||||
}
|
||||
},
|
||||
.requests = 0,
|
||||
.failures = 0
|
||||
},
|
||||
{
|
||||
.deviceName = "Dryer Power",
|
||||
@ -55,7 +59,9 @@ static t_mbusDevice devices[] = {
|
||||
{ .label = "power", .index = 4 },
|
||||
{ .label = "voltage", .index = 2 },
|
||||
{ .label = "current", .index = 3 }
|
||||
}
|
||||
},
|
||||
.requests = 0,
|
||||
.failures = 0
|
||||
},
|
||||
{
|
||||
.deviceName = "Laundry Power",
|
||||
@ -65,7 +71,9 @@ static t_mbusDevice devices[] = {
|
||||
{ .label = "power", .index = 4 },
|
||||
{ .label = "voltage", .index = 2 },
|
||||
{ .label = "current", .index = 3 }
|
||||
}
|
||||
},
|
||||
.requests = 0,
|
||||
.failures = 0
|
||||
},
|
||||
{
|
||||
.deviceName = "Dishwasher Power",
|
||||
@ -75,7 +83,9 @@ static t_mbusDevice devices[] = {
|
||||
{ .label = "power", .index = 4 },
|
||||
{ .label = "voltage", .index = 2 },
|
||||
{ .label = "current", .index = 3 }
|
||||
}
|
||||
},
|
||||
.requests = 0,
|
||||
.failures = 0
|
||||
},
|
||||
{
|
||||
.deviceName = "Light Power",
|
||||
@ -85,7 +95,9 @@ static t_mbusDevice devices[] = {
|
||||
{ .label = "power", .index = 4 },
|
||||
{ .label = "voltage", .index = 2 },
|
||||
{ .label = "current", .index = 3 }
|
||||
}
|
||||
},
|
||||
.requests = 0,
|
||||
.failures = 0
|
||||
},
|
||||
{
|
||||
.deviceName = "Freezer Power",
|
||||
@ -95,7 +107,9 @@ static t_mbusDevice devices[] = {
|
||||
{ .label = "power", .index = 4 },
|
||||
{ .label = "voltage", .index = 2 },
|
||||
{ .label = "current", .index = 3 }
|
||||
}
|
||||
},
|
||||
.requests = 0,
|
||||
.failures = 0
|
||||
},
|
||||
{
|
||||
.deviceName = "Fridge Power",
|
||||
@ -105,7 +119,9 @@ static t_mbusDevice devices[] = {
|
||||
{ .label = "power", .index = 4 },
|
||||
{ .label = "voltage", .index = 2 },
|
||||
{ .label = "current", .index = 3 }
|
||||
}
|
||||
},
|
||||
.requests = 0,
|
||||
.failures = 0
|
||||
}
|
||||
};
|
||||
|
||||
@ -115,7 +131,11 @@ void triggerMBusRequest(void *handle) {
|
||||
static uint32_t cnt = 0;
|
||||
|
||||
logMsg("");
|
||||
logMsg("*** NEW REQUEST %s %d %d ***", devices[deviceIndex].deviceName, deviceIndex, cnt);
|
||||
logMsg("*** NEW REQUEST %s %d %d %d %d ***",
|
||||
devices[deviceIndex].deviceName,
|
||||
devices[deviceIndex].requests,
|
||||
devices[deviceIndex].failures,
|
||||
deviceIndex, cnt);
|
||||
mbusCommRequest(&(devices[deviceIndex]));
|
||||
|
||||
cnt++;
|
||||
|
@ -351,6 +351,7 @@ static void handleRequestEngine(void *handle) {
|
||||
|
||||
case MBCS_TIMEOUT:
|
||||
logMsg("hre state TIMEOUT");
|
||||
localMbusCommHandle->device->failures += 1;
|
||||
localMbusCommHandle->receiving = false;
|
||||
if (localMbusCommHandle->frame.userdata != NULL) {
|
||||
free(localMbusCommHandle->frame.userdata);
|
||||
@ -398,6 +399,7 @@ e_mbusCommRequestResult mbusCommRequest(t_mbusDevice *mbusDevice) {
|
||||
mbusCommHandle.cmd = MBUS_QUERY_CMD;
|
||||
mbusCommHandle.addr = mbusDevice->address;
|
||||
mbusCommHandle.device = mbusDevice;
|
||||
mbusDevice->requests += 1;
|
||||
schAdd(handleRequestEngine, (void*) &mbusCommHandle, 0, 0);
|
||||
res = MBCRR_TRIGGERED;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user