Group=network_fw
Type=dbus
BusName=org.bluez.mesh
-ExecStart=@pkglibexecdir@/bluetooth-meshd --nodetach --debug
+ExecStart=@pkglibexecdir@/bluetooth-meshd --nodetach --debug --use_raw
Capabilities=cap_net_admin,cap_net_bind_service,cap_dac_override=eip
SecureBits=keep-caps
SmackProcessLabel=System
static const char *mesh_conf_fname;
static enum mesh_io_type io_type;
static void *io_opts;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+bool use_raw = false;
+#endif
static const struct option main_options[] = {
{ "io", required_argument, NULL, 'i' },
{ "nodetach", no_argument, NULL, 'n' },
{ "debug", no_argument, NULL, 'd' },
{ "dbus-debug", no_argument, NULL, 'b' },
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ { "use_raw", no_argument, NULL, 'r' },
+#endif
{ "help", no_argument, NULL, 'h' },
{ }
};
static bool parse_io(const char *optarg, enum mesh_io_type *type, void **opts)
{
if (strstr(optarg, "generic") == optarg) {
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ struct mesh_io_opts *m_io_opts = l_new(struct mesh_io_opts, 1);
+ int *index = &(m_io_opts->index);
+ m_io_opts->use_raw = use_raw;
+ *opts = m_io_opts;
+#else
int *index = l_new(int, 1);
-
- *type = MESH_IO_TYPE_GENERIC;
*opts = index;
+#endif
+ *type = MESH_IO_TYPE_GENERIC;
optarg += strlen("generic");
if (!*optarg) {
for (;;) {
int opt;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ opt = getopt_long(argc, argv, "i:c:f:ndbhr", main_options, NULL);
+#else
opt = getopt_long(argc, argv, "i:c:f:ndbh", main_options, NULL);
+#endif
if (opt < 0)
break;
case 'b':
dbus_debug = true;
break;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ case 'r':
+ use_raw = true;
+ break;
+#endif
case 'h':
usage();
status = EXIT_SUCCESS;
uint16_t interval;
bool sending;
bool active;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ bool use_raw;
+#endif
};
struct pvt_rx_reg {
cmd_slem.mask[6] = 0x00;
cmd_slem.mask[7] = 0x00;
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ if (!(io->use_raw)) {
+ /* Reset Command in case of user channel */
+ bt_hci_send(io->hci, BT_HCI_CMD_RESET, NULL, 0, hci_generic_callback,
+ NULL, NULL);
+ }
+#else
/* TODO: Move to suitable place. Set suitable masks */
/* Reset Command */
bt_hci_send(io->hci, BT_HCI_CMD_RESET, NULL, 0, hci_generic_callback,
NULL, NULL);
+#endif
/* Read local supported commands */
bt_hci_send(io->hci, BT_HCI_CMD_READ_LOCAL_COMMANDS, NULL, 0,
bt_hci_unref(io->pvt->hci);
}
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ if (io->pvt->use_raw) {
+ l_debug("Use HCI RAW channel");
+
+ /* Power up HCI device */
+ uint16_t mode = 0x01;
+ if (!set_powered(mode, io->pvt->index))
+ return;
+
+ io->pvt->hci = bt_hci_new_raw_device(io->pvt->index);
+ } else {
+ l_debug("Use HCI USER channel");
+ io->pvt->hci = bt_hci_new_user_channel(io->pvt->index);
+ }
+#else
io->pvt->hci = bt_hci_new_user_channel(io->pvt->index);
+#endif
+
if (!io->pvt->hci) {
l_error("Failed to start mesh io (hci %u): %s", io->pvt->index,
strerror(errno));
return false;
io->pvt = l_new(struct mesh_io_private, 1);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+ struct mesh_io_opts *io_opts;
+ io_opts = (struct mesh_io_opts *)opts;
+ io->pvt->index = io_opts->index;
+ io->pvt->use_raw = io_opts->use_raw;
+#else
io->pvt->index = *(int *)opts;
+#endif
io->pvt->rx_regs = l_queue_new();
io->pvt->tx_pkts = l_queue_new();
int8_t rssi;
};
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+struct mesh_io_opts {
+ int index;
+ bool use_raw;
+};
+#endif
+
struct mesh_io_send_info {
enum mesh_io_timing_type type;
union {
reg->cb(index, reg->user_data);
}
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+static void set_powered_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ int index = L_PTR_TO_UINT(user_data);
+ uint32_t settings;
+
+ if (status != MGMT_STATUS_SUCCESS) {
+ l_error("Failed to set powered: %s (0x%02x)",
+ mgmt_errstr(status), status);
+ return;
+ }
+
+ settings = l_get_le32(param);
+
+ if (!(settings & MGMT_SETTING_POWERED)) {
+ l_error("Controller is not powered");
+ return;
+ }
+
+ l_debug("set powered success on index %d", index);
+ /** <TO-DO> update current settings of adapter */
+}
+
+bool set_powered(uint16_t mode, int index)
+{
+ struct mgmt_mode cp;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.val = mode;
+
+ /** <TO-DO> check current settings of adapter */
+ if (mgmt_send(mgmt_mesh, MGMT_OP_SET_POWERED, index, sizeof(cp), &cp,
+ set_powered_complete, L_UINT_TO_PTR(index), NULL) > 0)
+
+ return true;
+
+ return false;
+}
+#endif
+
static void read_info_cb(uint8_t status, uint16_t length,
const void *param, void *user_data)
{
if (current_settings & MGMT_SETTING_POWERED) {
l_info("Controller hci %u is in use", index);
+#ifndef TIZEN_FEATURE_BLUEZ_MODIFY
return;
+#endif
}
if (!(supported_settings & MGMT_SETTING_LE)) {
typedef void (*mesh_mgmt_read_info_func_t)(int index, void *user_data);
bool mesh_mgmt_list(mesh_mgmt_read_info_func_t cb, void *user_data);
+
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+bool set_powered(uint16_t mode, int index);
+#endif