summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kocialkowski <contact@paulk.fr>2012-08-13 13:50:06 (GMT)
committerPaul Kocialkowski <contact@paulk.fr>2012-08-13 13:50:06 (GMT)
commitf952dde8f3a29634be1c8fa19b8eed367c1ad878 (patch)
treefe3b89d6b3ffb9214cb327734e76dfcecc3bf80e
parent273a537e06a1ea1351e76d5e49a12794732cf7bb (diff)
downloadbcm4751-f952dde8f3a29634be1c8fa19b8eed367c1ad878.zip
bcm4751-f952dde8f3a29634be1c8fa19b8eed367c1ad878.tar.gz
bcm4751-f952dde8f3a29634be1c8fa19b8eed367c1ad878.tar.bz2
MEIF: Added dispatch
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r--meif.c29
-rw-r--r--meif.h2
2 files changed, 29 insertions, 2 deletions
diff --git a/meif.c b/meif.c
index 0fdf813..8d99a27 100644
--- a/meif.c
+++ b/meif.c
@@ -108,6 +108,31 @@ void meif_message_log(struct meif_message *meif_message)
hex_dump(meif_message->data, meif_message->length);
}
+int meif_dispatch(struct meif_message *meif_message)
+{
+ struct meif_config_values *config_values;
+
+ switch(meif_message->command) {
+ case MEIF_ACK_MSG:
+ printf("Got an ACK message\n\n");
+ break;
+ case MEIF_NACK_MSG:
+ printf("Got a NACK message\n\n");
+ break;
+ case MEIF_STATE_REPORT_MSG:
+ printf("Got a STATE_REPORT message\n\n");
+ break;
+ case MEIF_CONFIG_VALUES_MSG:
+ if(meif_message->data != NULL && meif_message->length >= sizeof(struct meif_config_values)) {
+ config_values = (struct meif_config_values *) meif_message->data;
+ printf("Got config values:\n\tvendor: %s\n\tproduct: %s\n\n", config_values->vendor, config_values->product);
+ }
+ break;
+ }
+
+ return 0;
+}
+
void meif_read_loop(int fd)
{
void *data = NULL;
@@ -234,7 +259,9 @@ void meif_read_loop(int fd)
if(meif_message != NULL) {
meif_message_log(meif_message);
- // TODO: dispatch
+ rc = meif_dispatch(meif_message);
+ if(rc < 0)
+ run = 0;
meif_message_free(meif_message);
}
}
diff --git a/meif.h b/meif.h
index 2652529..ded67f3 100644
--- a/meif.h
+++ b/meif.h
@@ -57,7 +57,7 @@ struct meif_message {
void *data;
} __attribute__((__packed__));
-struct meif_config_values_report {
+struct meif_config_values {
uint8_t unknown1[36];
char vendor[16];
char product[16];