/** * 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); } }
/* * Configure HID results */ static int config_hid(prop_dictionary_t dict, sdp_data_t *rec) { prop_object_t obj; int32_t control_psm, interrupt_psm, reconnect_initiate, hid_length; uint8_t *hid_descriptor; sdp_data_t value; const char *mode; uint16_t attr; control_psm = -1; interrupt_psm = -1; reconnect_initiate = -1; hid_descriptor = NULL; hid_length = -1; while (sdp_get_attr(rec, &attr, &value)) { switch (attr) { case SDP_ATTR_PROTOCOL_DESCRIPTOR_LIST: control_psm = parse_pdl(&value, SDP_UUID_PROTOCOL_L2CAP); break; case SDP_ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LISTS: interrupt_psm = parse_apdl(&value, SDP_UUID_PROTOCOL_L2CAP); break; case 0x0205: /* HIDReconnectInitiate */ reconnect_initiate = parse_boolean(&value); break; case 0x0206: /* HIDDescriptorList */ if (parse_hid_descriptor(&value)) { hid_descriptor = value.next; hid_length = value.end - value.next; } break; default: break; } } if (control_psm == -1 || interrupt_psm == -1 || reconnect_initiate == -1 || hid_descriptor == NULL || hid_length == -1) return ENOATTR; obj = prop_string_create_cstring_nocopy("bthidev"); if (obj == NULL || !prop_dictionary_set(dict, BTDEVtype, obj)) return errno; prop_object_release(obj); obj = prop_number_create_integer(control_psm); if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVcontrolpsm, obj)) return errno; prop_object_release(obj); obj = prop_number_create_integer(interrupt_psm); if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVinterruptpsm, obj)) return errno; prop_object_release(obj); obj = prop_data_create_data(hid_descriptor, hid_length); if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVdescriptor, obj)) return errno; mode = hid_mode(obj); prop_object_release(obj); obj = prop_string_create_cstring_nocopy(mode); if (obj == NULL || !prop_dictionary_set(dict, BTDEVmode, obj)) return errno; prop_object_release(obj); if (!reconnect_initiate) { obj = prop_bool_create(true); if (obj == NULL || !prop_dictionary_set(dict, BTHIDEVreconnect, obj)) return errno; prop_object_release(obj); } return 0; }