static void service_changed_cb(uint16_t start_handle, uint16_t end_handle, void *user_data) { struct client *cli = user_data; struct bt_gatt_service_iter iter; const bt_gatt_service_t *service; if (!bt_gatt_service_iter_init(&iter, cli->gatt)) { PRLOG("Failed to initialize service iterator\n"); return; } printf("\nService Changed handled - start: 0x%04x end: 0x%04x\n", start_handle, end_handle); if (!bt_gatt_service_iter_next_by_handle(&iter, start_handle, &service)) return; print_service(service); while (bt_gatt_service_iter_next(&iter, &service)) { if (service->start_handle >= end_handle) break; print_service(service); } print_prompt(); }
static void list_service_array(DBusMessageIter *iter) { DBusMessageIter array, dict; char *path = NULL; while (dbus_message_iter_get_arg_type(iter) == DBUS_TYPE_STRUCT) { dbus_message_iter_recurse(iter, &array); if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_OBJECT_PATH) return; dbus_message_iter_get_basic(&array, &path); dbus_message_iter_next(&array); if (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_ARRAY) { dbus_message_iter_recurse(&array, &dict); print_service(path, &dict); } if (dbus_message_iter_has_next(iter)) fprintf(stdout, "\n"); dbus_message_iter_next(iter); } }
void nextconfig (const char *file) { #ifndef IPV6 struct servent *sp; #endif struct servtab *sep, **sepp; struct passwd *pwd; FILE *fconfig; SIGSTATUS sigstatus; size_t line = 0; fconfig = setconfig (file); if (!fconfig) { syslog (LOG_ERR, "%s: %m", file); return; } while ((sep = getconfigent (fconfig, file, &line))) { if ((pwd = getpwnam (sep->se_user)) == NULL) { syslog (LOG_ERR, "%s/%s: No such user '%s', service ignored", sep->se_service, sep->se_proto, sep->se_user); continue; } if (ISMUX (sep)) { sep->se_fd = -1; sep->se_checked = 1; enter (sep); } else expand_enter (sep); freeconfig (sep); } endconfig (fconfig); /* * Purge anything not looked at above. */ signal_block (&sigstatus); sepp = &servtab; while ((sep = *sepp)) { if (sep->se_checked) { sepp = &sep->se_next; continue; } *sepp = sep->se_next; if (sep->se_fd >= 0) close_sep (sep); if (debug) print_service ("FREE", sep); freeconfig (sep); free (sep); } signal_unblock (&sigstatus); }
static void service_print_v2(const void *ip, const struct xt_entry_match *match, int numeric) { struct xt_service_info_v2 *info = (struct xt_service_info_v2 *) match->data; print_service(info->type, info->name_match, info->name, info->flags); }
void gatt_remove_service(GDBusProxy *proxy) { GList *l; l = g_list_find(services, proxy); if (!l) return; services = g_list_delete_link(services, l); print_service(proxy, COLORED_DEL); }
static void print_services_by_handle(struct client *cli, uint16_t handle) { struct bt_gatt_service_iter iter; const bt_gatt_service_t *service; if (!bt_gatt_service_iter_init(&iter, cli->gatt)) { PRLOG("Failed to initialize service iterator\n"); return; } printf("\n"); while (bt_gatt_service_iter_next_by_handle(&iter, handle, &service)) print_service(service); }
static void print_services_by_uuid(struct client *cli, const bt_uuid_t *uuid) { struct bt_gatt_service_iter iter; const bt_gatt_service_t *service; if (!bt_gatt_service_iter_init(&iter, cli->gatt)) { PRLOG("Failed to initialize service iterator\n"); return; } printf("\n"); while (bt_gatt_service_iter_next_by_uuid(&iter, uuid->value.u128.data, &service)) print_service(service); }
int help_arg (char *rtn) { int i; for (i = 0; help_info[i].command != 0; i++) if (strcmp (help_info[i].command, rtn) == 0) { if (help_info[i].serv) { ps_printf (RPS, "%-10s - %s\n[<object>] %s ", rtn, help_info[i].use,help_info[i].args); print_other(RPS,help_info[i].other); ps_print (RPS,"\n"); print_service(); } else ps_printf (RPS, "%-10s - %s\n%s\n", rtn, help_info[i].use,help_info[i].args); return; } ps_print (OPT,"Sorry - No help available\n"); }
/* * Main Loop */ int main() { motor_init(); button_init(); log_init(); g_tick = 0; LOG(LVL_INFO, "------------------------"); LOG(LVL_INFO, "Starting application"); while(1) { g_tick++; /* note: will roll over */ motor_serviceEncoders(); motor_drive(); button_readState(); print_service(); log_service(); } }
static void list_attributes(const char *path, GList *source) { GList *l; for (l = source; l; l = g_list_next(l)) { GDBusProxy *proxy = l->data; const char *proxy_path; proxy_path = g_dbus_proxy_get_path(proxy); if (!g_str_has_prefix(proxy_path, path)) continue; if (source == services) { print_service(proxy, NULL); list_attributes(proxy_path, characteristics); } else if (source == characteristics) { print_characteristic(proxy, NULL); list_attributes(proxy_path, descriptors); } else if (source == descriptors) print_descriptor(proxy, NULL); } }
void gatt_remove_service(GDBusProxy *proxy) { services = g_list_remove(services, proxy); print_service(proxy, COLORED_DEL); }
void gatt_add_service(GDBusProxy *proxy) { services = g_list_append(services, proxy); print_service(proxy, COLORED_NEW); }
struct servtab * enter (struct servtab *cp) { struct servtab *sep; SIGSTATUS sigstatus; int i; /* Checking/Removing duplicates */ for (sep = servtab; sep; sep = sep->se_next) if (memcmp (&sep->se_ctrladdr, &cp->se_ctrladdr, sizeof (sep->se_ctrladdr)) == 0 && strcmp (sep->se_service, cp->se_service) == 0 && strcmp (sep->se_proto, cp->se_proto) == 0 && ISMUX (sep) == ISMUX (cp)) break; if (sep != 0) { signal_block (&sigstatus); /* * sep->se_wait may be holding the pid of a daemon * that we're waiting for. If so, don't overwrite * it unless the config file explicitly says don't * wait. */ if (cp->se_bi == 0 && (sep->se_wait == 1 || cp->se_wait == 0)) sep->se_wait = cp->se_wait; #define SWAP(a, b) { char *c = a; a = b; b = c; } if (cp->se_user) SWAP (sep->se_user, cp->se_user); if (cp->se_server) SWAP (sep->se_server, cp->se_server); argcv_free (sep->se_argc, sep->se_argv); sep->se_argc = cp->se_argc; sep->se_argv = cp->se_argv; cp->se_argc = 0; cp->se_argv = NULL; sep->se_checked = 1; signal_unblock (&sigstatus); if (debug) print_service ("REDO", sep); return sep; } if (debug) print_service ("ADD ", cp); sep = (struct servtab *) malloc (sizeof (*sep)); if (sep == NULL) { syslog (LOG_ERR, "Out of memory."); exit (-1); } *sep = *cp; dupstr (&sep->se_node); dupstr (&sep->se_service); dupstr (&sep->se_proto); dupstr (&sep->se_user); dupstr (&sep->se_server); dupmem ((void**)&sep->se_argv, sep->se_argc * sizeof (sep->se_argv[0])); for (i = 0; i < sep->se_argc; i++) dupstr (&sep->se_argv[i]); sep->se_fd = -1; signal_block (&sigstatus); sep->se_next = servtab; servtab = sep; signal_unblock (&sigstatus); return sep; }