/** * processNode: * @reader: the xmlReader * * Dump information about the current node */ static void processNode(xmlTextReaderPtr reader) { int depth, type; type = xmlTextReaderNodeType(reader); if ((type == XML_ELEMENT_DECL) || (type == XML_DTD_NODE)) return; depth = xmlTextReaderDepth(reader); if ((type == XML_ELEMENT_NODE) && (depth == 2)) printf("\n"); if (2 == depth) printf("\t"); else if (3 == depth) printf("\t\t"); xmlNodePtr node = xmlTextReaderCurrentNode(reader); if (xmlTextReaderNodeType(reader) == XML_ELEMENT_NODE && node && node->properties) { xmlAttr *attribute = node->properties; while (attribute && attribute->name && attribute->children) { tag = xmlNodeListGetString(node->doc, attribute->children, 1); printf ("%s%c", tag, (depth == 2) ? '\n' : ':'); bdaddr = strtoba((const char *)tag); if (bdaddr) add_remote_device(bdaddr); attribute = attribute->next; /* tag name is what we need */ break; } } if (xmlTextReaderNodeType(reader) == XML_TEXT_NODE) { if (xmlStrstr((xmlChar *)"Service", tag)) parse_services(reader); else if (xmlStrstr((xmlChar *)"HidDescriptor", tag)) parse_hid_descriptor(reader); else if (xmlStrstr((xmlChar *)"HogpRpt", tag)) parse_hogp(reader); else if (xmlStrstr((xmlChar *)"GattAttrs", tag)) parse_gatt_attribute(reader); else if (xmlStrstr((xmlChar *)"DevClass", tag)) parse_dev_class(reader); else if (xmlStrstr((xmlChar *)"Timestamp", tag)) parse_timestamp(reader); else if (xmlStrstr((xmlChar *)"Address", tag)) parse_bdaddr(reader); else parse_text_node(reader); } }
static void remote_device_properties_cb(bt_status_t status, bt_bdaddr_t *bd_addr, int num_properties, bt_property_t *properties) { haltest_info("%s: status=%s bd_addr=%s num_properties=%d\n", __func__, bt_status_t2str(status), bdaddr2str(bd_addr), num_properties); add_remote_device(bd_addr); dump_properties(num_properties, properties); }
static void add_remote_device_from_props(int num_properties, const bt_property_t *properties) { int i; for (i = 0; i < num_properties; i++) { /* * properities sometimes come unaligned hence memcp to * aligned buffer */ bt_property_t property; memcpy(&property, properties + i, sizeof(property)); if (property.type == BT_PROPERTY_BDADDR) add_remote_device((bt_bdaddr_t *) property.val); } }