}
/**
+ * @brief returns record type for external type
+ * Validate type and type length and returns
+ * type.
+ *
+ * @param type Type name in hex foarmat
+ * @param type_lenth Type name length
+ *
+ * @return enum record type
+ */
+
+static enum record_type get_external_record_type(uint8_t *type,
+ size_t type_length)
+{
+ DBG("");
+
+ if (strncmp((char *) type, "nokia.com:bt", 12) == 0)
+ return RECORD_TYPE_MIME_TYPE;
+ else
+ return RECORD_TYPE_UNKNOWN;
+}
+
+/**
* @brief returns record type
* Validate type name format, type and type length and returns
* type.
switch (tnf) {
case RECORD_TNF_EMPTY:
case RECORD_TNF_URI:
- case RECORD_TNF_EXTERNAL:
case RECORD_TNF_UNKNOWN:
case RECORD_TNF_UNCHANGED:
break;
case RECORD_TNF_MIME:
return RECORD_TYPE_MIME_TYPE;
+ case RECORD_TNF_EXTERNAL:
+ return get_external_record_type(type, type_length);
+
}
return RECORD_TYPE_UNKNOWN;
uint32_t payload_length)
{
struct near_ndef_mime_record *mime = NULL;
+ int err = 0;
DBG("");
mime->type = g_strdup(record->header->type_name);
DBG("MIME Type '%s'", mime->type);
+ if (strcmp(mime->type, "application/vnd.bluetooth.ep.oob") == 0) {
+ err = __near_bt_parse_oob_record(BT_MIME_V2_1,
+ &ndef_data[offset]);
+ } else {
+ if (strcmp(mime->type, "nokia.com:bt") == 0) {
+ err = __near_bt_parse_oob_record(BT_MIME_V2_0,
+ &ndef_data[offset]);
+ }
+ else
+ err = -EOPNOTSUPP;
+ }
+
+ if (err < 0) {
+ DBG("Parsing mime error %d", err);
+ g_free(mime->type);
+ g_free(mime);
+ return NULL;
+ }
return mime;
}
int __near_plugin_init(const char *pattern, const char *exclude);
void __near_plugin_cleanup(void);
+
+/* NFC Bluetooth Secure Simple Pairing */
+#define BT_MIME_V2_0 0
+#define BT_MIME_V2_1 1
+
+int __near_bluetooth_init(void);
+void __near_bluetooth_cleanup(void);
+int __near_bt_parse_oob_record(uint8_t version, uint8_t *bt_data);