lots of changes
diff --git a/objects/fan_generic_obj.c b/objects/fan_generic_obj.c
index 5dad61f..4c2ca35 100644
--- a/objects/fan_generic_obj.c
+++ b/objects/fan_generic_obj.c
@@ -41,17 +41,6 @@
return TRUE;
}
-static gboolean
-on_set_config (FruFan *fan,
- GDBusMethodInvocation *invocation,
- gchar** config,
- gpointer user_data)
-{
- fru_fan_complete_set_config_data(fan,invocation);
- return TRUE;
-}
-
-
static void
on_bus_acquired (GDBusConnection *connection,
const gchar *name,
@@ -91,10 +80,6 @@
"handle-set-speed",
G_CALLBACK (on_set_speed),
NULL); /* user_data */
- g_signal_connect (fan,
- "handle-set-config-data",
- G_CALLBACK (on_set_config),
- NULL); /* user_data */
//g_timeout_add(poll_interval, poll_sensor, object);
diff --git a/objects/fru_board_obj.c b/objects/fru_board_obj.c
new file mode 100644
index 0000000..47683db
--- /dev/null
+++ b/objects/fru_board_obj.c
@@ -0,0 +1,121 @@
+#include "interfaces/fru.h"
+#include "openbmc.h"
+
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static const gchar* dbus_object_path = "/org/openbmc/frus/Board";
+static const gchar* dbus_name = "org.openbmc.frus.Board";
+static const guint poll_interval = 5000;
+static guint heartbeat = 0;
+
+static GDBusObjectManagerServer *manager = NULL;
+
+static gboolean
+on_init (Fru *fru,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+
+ FruEeprom *eeprom = object_get_fru_eeprom((Object*)user_data);
+
+ const gchar* dev_path = fru_eeprom_get_i2c_dev_path(eeprom);
+ const gchar* addr = fru_eeprom_get_i2c_address(eeprom);
+ g_print("Reading VPD EERPROM at: %s, %s\n",dev_path, addr);
+ fru_complete_init(fru,invocation);
+ fru_set_part_num(fru,"test part num");
+
+ // add eeprom read code here
+ fru_emit_cache_me(fru,dbus_name);
+
+ return TRUE;
+}
+
+static void
+on_bus_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ g_print ("Acquired a message bus connection: %s\n",name);
+
+ cmdline *cmd = user_data;
+ if (cmd->argc < 2)
+ {
+ g_print("No objects created. Put object name(s) on command line\n");
+ return;
+ }
+ manager = g_dbus_object_manager_server_new (dbus_object_path);
+ int i=0;
+ for (i=1;i<cmd->argc;i++)
+ {
+ gchar *s;
+ s = g_strdup_printf ("%s/%s",dbus_object_path,cmd->argv[i]);
+ ObjectSkeleton *object = object_skeleton_new (s);
+ g_free (s);
+
+ Fru *fru = fru_skeleton_new ();
+ object_skeleton_set_fru (object, fru);
+ g_object_unref (fru);
+
+ FruEeprom *eeprom = fru_eeprom_skeleton_new ();
+ object_skeleton_set_fru_eeprom (object, eeprom);
+ g_object_unref (eeprom);
+
+ g_signal_connect (fru,
+ "handle-init",
+ G_CALLBACK (on_init),
+ object); /* user_data */
+
+
+ /* Export the object (@manager takes its own reference to @object) */
+ g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
+ g_object_unref (object);
+ }
+
+ /* Export all objects */
+ g_dbus_object_manager_server_set_connection (manager, connection);
+}
+
+static void
+on_name_acquired (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ g_print ("Acquired the name %s\n", name);
+}
+
+static void
+on_name_lost (GDBusConnection *connection,
+ const gchar *name,
+ gpointer user_data)
+{
+ g_print ("Lost the name %s\n", name);
+}
+
+
+gint
+main (gint argc, gchar *argv[])
+{
+ GMainLoop *loop;
+ cmdline cmd;
+ cmd.argc = argc;
+ cmd.argv = argv;
+ guint id;
+ loop = g_main_loop_new (NULL, FALSE);
+
+ id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ dbus_name,
+ G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT |
+ G_BUS_NAME_OWNER_FLAGS_REPLACE,
+ on_bus_acquired,
+ on_name_acquired,
+ on_name_lost,
+ &cmd,
+ NULL);
+
+ g_main_loop_run (loop);
+
+ g_bus_unown_name (id);
+ g_main_loop_unref (loop);
+ return 0;
+}
diff --git a/objects/sensor_host_status_obj.c b/objects/sensor_host_status_obj.c
index df5c326..29545d1 100644
--- a/objects/sensor_host_status_obj.c
+++ b/objects/sensor_host_status_obj.c
@@ -1,4 +1,4 @@
-#include "interfaces/sensor2.h"
+#include "interfaces/sensor.h"
#include "openbmc.h"
@@ -32,16 +32,17 @@
}
static gboolean
-on_set_config (SensorInteger *sen,
+on_set (SensorInteger *sen,
GDBusMethodInvocation *invocation,
- gchar** config,
+ guint value,
gpointer user_data)
{
- sensor_integer_complete_set_config_data(sen,invocation);
- return TRUE;
+ sensor_integer_set_value(sen,value);
+ sensor_integer_emit_changed(sen,value,sensor_integer_get_units(sen));
+ sensor_integer_complete_set_value(sen,invocation);
+ return TRUE;
}
-
static void
on_bus_acquired (GDBusConnection *connection,
const gchar *name,
@@ -69,7 +70,7 @@
g_object_unref (sensor);
// set units
- sensor_integer_set_units(sensor,"C");
+ sensor_integer_set_units(sensor,"");
//define method callbacks here
g_signal_connect (sensor,
"handle-get-value",
@@ -79,12 +80,10 @@
"handle-get-units",
G_CALLBACK (on_get_units),
NULL); /* user_data */
-
g_signal_connect (sensor,
- "handle-set-config-data",
- G_CALLBACK (on_set_config),
+ "handle-set-value",
+ G_CALLBACK (on_set),
NULL); /* user_data */
-
/* Export the object (@manager takes its own reference to @object) */
g_dbus_object_manager_server_export (manager, G_DBUS_OBJECT_SKELETON (object));
diff --git a/objects/sensor_temperature_ambient_obj.c b/objects/sensor_temperature_ambient_obj.c
index 848c786..52335d5 100644
--- a/objects/sensor_temperature_ambient_obj.c
+++ b/objects/sensor_temperature_ambient_obj.c
@@ -1,4 +1,4 @@
-#include "interfaces/sensor2.h"
+#include "interfaces/sensor.h"
#include "openbmc.h"
#include "sensor_threshold.h"
@@ -12,8 +12,6 @@
static GDBusObjectManagerServer *manager = NULL;
-static gchar* i2c_bus = "";
-static gchar* i2c_address = "";
static gboolean inited = FALSE;
static gboolean
@@ -25,8 +23,11 @@
}
SensorInteger *sensor = object_get_sensor_integer((Object*)user_data);
SensorIntegerThreshold *threshold = object_get_sensor_integer_threshold((Object*)user_data);
+ SensorI2c *i2c = object_get_sensor_i2c((Object*)user_data);
+
guint value = sensor_integer_get_value(sensor);
//TOOD: Change to actually read sensor
+ g_print("Reading I2C = %s; Address = %s\n",sensor_i2c_get_dev_path(i2c),sensor_i2c_get_address(i2c));
value = value+1;
if (heartbeat > 10000)
{
@@ -44,7 +45,7 @@
if (value != sensor_integer_get_value(sensor))
{
sensor_integer_set_value(sensor,value);
- sensor_integer_emit_changed(sensor,value);
+ sensor_integer_emit_changed(sensor,value,sensor_integer_get_units(sensor));
check_thresholds(threshold,value);
}
return TRUE;
@@ -56,7 +57,6 @@
gpointer user_data)
{
inited = TRUE;
- g_print("Sensor init");
sensor_integer_complete_init(sen,invocation);
return TRUE;
}
@@ -82,19 +82,6 @@
return TRUE;
}
-static gboolean
-on_set_config (SensorInteger *sen,
- GDBusMethodInvocation *invocation,
- gchar** config,
- gpointer user_data)
-{
- g_print("I2C bus = %s\n",config[0]);
- g_print("I2C addr = %s\n",config[1]);
- sensor_integer_complete_set_config_data(sen,invocation);
- return TRUE;
-}
-
-
static void
on_bus_acquired (GDBusConnection *connection,
const gchar *name,
@@ -125,6 +112,11 @@
object_skeleton_set_sensor_integer_threshold (object,threshold);
g_object_unref (threshold);
+ SensorI2c *i2c = sensor_i2c_skeleton_new();
+ object_skeleton_set_sensor_i2c (object,i2c);
+ g_object_unref (i2c);
+
+
// set units
sensor_integer_set_units(sensor,"C");
sensor_integer_threshold_set_state(threshold,NOT_SET);
@@ -138,11 +130,6 @@
G_CALLBACK (on_get_units),
NULL); /* user_data */
- g_signal_connect (sensor,
- "handle-set-config-data",
- G_CALLBACK (on_set_config),
- NULL); /* user_data */
-
g_signal_connect (sensor,
"handle-init",
G_CALLBACK (on_init),