return true;
}
-gboolean handle_i2c_init(
+gboolean handle_i2c_open(
PeripheralIoGdbusI2c *i2c,
GDBusMethodInvocation *invocation,
gint bus,
+ gint address,
gint fd,
gpointer user_data)
{
struct _peripheral_i2c_s st_i2c;
// TODO: Create i2c instance
-
- ret = peripheral_bus_i2c_init(&st_i2c, bus);
- peripheral_io_gdbus_i2c_complete_init(i2c, invocation, st_i2c.fd, ret);
+ ret = peripheral_bus_i2c_open(&st_i2c, bus, address);
+ peripheral_io_gdbus_i2c_complete_open(i2c, invocation, st_i2c.fd, ret);
return true;
}
-gboolean handle_i2c_stop(
+gboolean handle_i2c_close(
PeripheralIoGdbusI2c *i2c,
GDBusMethodInvocation *invocation,
gint fd,
st_i2c.fd = fd;
- ret = peripheral_bus_i2c_stop(&st_i2c);
- peripheral_io_gdbus_i2c_complete_stop(i2c, invocation, ret);
-
- return true;
-}
-
-gboolean handle_i2c_set_address(
- PeripheralIoGdbusI2c *i2c,
- GDBusMethodInvocation *invocation,
- gint fd,
- gint addr,
- gpointer user_data)
-{
- peripheral_error_e ret = PERIPHERAL_ERROR_NONE;
- struct _peripheral_i2c_s st_i2c;
-
- st_i2c.fd = fd;
-
- ret = peripheral_bus_i2c_set_address(&st_i2c, addr);
- peripheral_io_gdbus_i2c_complete_set_address(i2c, invocation, ret);
+ ret = peripheral_bus_i2c_close(&st_i2c);
+ peripheral_io_gdbus_i2c_complete_close(i2c, invocation, ret);
return true;
}
/* Add interface to default object path */
i2c_skeleton = peripheral_io_gdbus_i2c_skeleton_new();
g_signal_connect(i2c_skeleton,
- "handle-init",
- G_CALLBACK(handle_i2c_init),
- NULL);
- g_signal_connect(i2c_skeleton,
- "handle-stop",
- G_CALLBACK(handle_i2c_stop),
+ "handle-open",
+ G_CALLBACK(handle_i2c_open),
NULL);
g_signal_connect(i2c_skeleton,
- "handle-set-address",
- G_CALLBACK(handle_i2c_set_address),
+ "handle-close",
+ G_CALLBACK(handle_i2c_close),
NULL);
g_signal_connect(i2c_skeleton,
"handle-read",
#include "i2c.h"
#include "peripheral_common.h"
-int peripheral_bus_i2c_init(peripheral_i2c_h i2c, int bus)
+int peripheral_bus_i2c_open(peripheral_i2c_h i2c, int bus, int address)
{
- return i2c_open(bus, &i2c->fd);
-}
+ int ret;
+
+ if ((ret = i2c_open(bus, &i2c->fd)) < 0)
+ return ret;
-int peripheral_bus_i2c_set_address(peripheral_i2c_h i2c, int address)
-{
return i2c_set_address(i2c->fd, address);
}
return i2c_write(i2c->fd, data, length);
}
-int peripheral_bus_i2c_stop(peripheral_i2c_h i2c)
+int peripheral_bus_i2c_close(peripheral_i2c_h i2c)
{
return i2c_close(i2c->fd);
}
#ifndef __PERIPHERAL_BUS_I2C_H__
#define __PERIPHERAL_BUS_I2C_H__
-int peripheral_bus_i2c_init(peripheral_i2c_h i2c, int bus);
+int peripheral_bus_i2c_open(peripheral_i2c_h i2c, int bus, int address);
int peripheral_bus_i2c_set_address(peripheral_i2c_h i2c, int address);
int peripheral_bus_i2c_read(peripheral_i2c_h i2c, int length, unsigned char * data);
int peripheral_bus_i2c_write(peripheral_i2c_h i2c, int length, unsigned char * data);
-int peripheral_bus_i2c_stop(peripheral_i2c_h i2c);
+int peripheral_bus_i2c_close(peripheral_i2c_h i2c);
#endif /* __PERIPHERAL_BUS_I2C_H__ */
</method>
</interface>
<interface name="org.tizen.peripheral_io.i2c">
- <method name="Init">
+ <method name="Open">
<arg type="i" name="bus" direction="in"/>
+ <arg type="i" name="address" direction="in"/>
<arg type="i" name="fd" direction="out"/>
<arg type="i" name="result" direction="out"/>
</method>
- <method name="Stop">
- <arg type="i" name="fd" direction="in"/>
- <arg type="i" name="result" direction="out"/>
- </method>
- <method name="SetAddress">
+ <method name="Close">
<arg type="i" name="fd" direction="in"/>
- <arg type="i" name="address" direction="in"/>
<arg type="i" name="result" direction="out"/>
</method>
<method name="Read">