- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 Swift 中创建一个 application/vnd.wfa.wsc 负载。我在这里找到了这篇适用于 Android 的帖子: Creating an NDEF WiFi record using application/vnd.wfa.wsc in Android
我坚持创建我想写在 NFC 标签上的有效载荷。我尝试将 java 代码转换为 swift 并将有效负载写入 NFC 标签,但我无法使用 Android 手机读取数据。
let VERSION: [UInt8] = [0x10, 0x4A]
let CREDENTIAL: [UInt8] = [0x10, 0x0e]
let AUTH_TYPE: [UInt8] = [0x10, 0x03]
let CRYPT_TYPE: [UInt8] = [0x10, 0x0F]
let MAC_ADDRESS: [UInt8] = [0x10, 0x20]
let NETWORK_IDX: [UInt8] = [0x10, 0x26]
let NETWORK_KEY: [UInt8] = [0x10, 0x27]
let NETWORK_NAME: [UInt8] = [0x10, 0x45]
let OOB_PASSWORD: [UInt8] = [0x10, 0x2C]
let VENDOR_EXT: [UInt8] = [0x10, 0x49]
let VENDOR_WFA: [UInt8] = [0x00, 0x37, 0x2A]
let VERSION2: [UInt8] = [0x00]
let KEY_SHAREABLE: [UInt8] = [0x02]
let AUTH_OPEN: [UInt8] = [0x00, 0x01]
let AUTH_WPA_PERSONAL: [UInt8] = [0x00, 0x02]
let AUTH_SHARED: [UInt8] = [0x00, 0x04]
let AUTH_WPA_ENTERPRISE: [UInt8] = [0x00, 0x08]
let AUTH_WPA2_ENTERPRISE: [UInt8] = [0x00, 0x10]
let AUTH_WPA2_PERSONAL: [UInt8] = [0x00, 0x20]
let AUTH_WPA_WPA2_PERSONAL: [UInt8] = [0x00, 0x22]
let CRYPT_NONE: [UInt8] = [0x00, 0x01]
let CRYPT_WEP: [UInt8] = [0x00, 0x02]
let CRYPT_TKIP: [UInt8] = [0x00, 0x04]
let CRYPT_AES: [UInt8] = [0x00, 0x08]
let CRYPT_AES_TKIP: [UInt8] = [0x00, 0x0C]
let credential: [UInt8] = [0x00, 0x36]
let idx: [UInt8] = [0x00, 0x01, 0x01]
let ssid = "TestWifi"
let password = "Test12345"
let ssidBytes: [UInt8] = Array(ssid.utf8)
let passwordBytes: [UInt8] = Array(password.utf8)
let authBytes: [UInt8] = Array("WPA PSK".utf8)
let lengthSSID: [UInt8] = [UInt8(ssid.lengthOfBytes(using: .utf8))]
let lengthPassword: [UInt8] = [UInt8(password.lengthOfBytes(using: .utf8))]
let cred: [UInt8] = CREDENTIAL + credential
let index: [UInt8] = NETWORK_IDX + idx
let network: [UInt8] = NETWORK_NAME + lengthSSID + ssidBytes
let auth: [UInt8] = AUTH_TYPE + AUTH_WPA_PERSONAL + authBytes
let crypt: [UInt8] = CRYPT_TYPE + CRYPT_WEP + CRYPT_AES_TKIP
let netw: [UInt8] = NETWORK_KEY + lengthPassword + passwordBytes
let foo1 = cred + index
let foo2 = network + auth
let foo3 = crypt + netw
let payload = foo1 + foo2 + foo3
let type = Data(base64Encoded: "application/vnd.wfa.wsc".base64Encoded()!)!
let identifier = Data(base64Encoded: "".base64Encoded()!)!
let payloadData = Data(bytes: payload, count: payload.count)
let payload = NFCNDEFPayload(format: .media, type: type, identifier: identifier, payload: payloadData)
谁能指出我做错了什么?
最佳答案
1) Credential TLV 由子 TLV[
以下是创建负载的 Swift 代码。 TODO:(1)我可能必须检查所需的字节序并重新排序各个字段(2)您可能需要检查此 API 的其他参数
import Foundation
import Glibc
/* TotalLen is count of all bytes in parenthesis.
CREDENTIAL + totallen +
(
NETWORK_IDX + Idxlen + idx
NETWORK_NAME + Namelen + ssidBytes
AUTH_TYPE + Authlen + AUTH_WPA_PERSONAL
CRYPT_TYPE + Cryptlen + AUTH_MIXED
NETWORK_KEY + Keylen + passwordBytes
MAC_ADDRESS + Maclen + addr
)
0x100E + **TotalLen** +
(0x1026 + 0x0001 + 01 +
0x1045 + 0x0008 + TestWifi +
0x1003 + 0x0002 + 0x0002 +
0x100F + 0x0002 + 0x000C (Mixed mode supporting TKIP, AES) +
0x1027 + 0x0009 + Test12345 +
0x1020 + 0x0006 + address) */
//Attributes
let VERSION: [UInt8] = [0x10, 0x4A]
let CREDENTIAL: [UInt8] = [0x10, 0x0e]
let AUTH_TYPE: [UInt8] = [0x10, 0x03]
let CRYPT_TYPE: [UInt8] = [0x10, 0x0F]
let MAC_ADDRESS: [UInt8] = [0x10, 0x20]
let NETWORK_IDX: [UInt8] = [0x10, 0x26]
let NETWORK_KEY: [UInt8] = [0x10, 0x27]
let NETWORK_NAME: [UInt8] = [0x10, 0x45]
let OOB_PASSWORD: [UInt8] = [0x10, 0x2C]
let VENDOR_EXT: [UInt8] = [0x10, 0x49]
let VENDOR_WFA: [UInt8] = [0x00, 0x37, 0x2A]
let VERSION2: [UInt8] = [0x00]
let KEY_SHAREABLE: [UInt8] = [0x02]
let AUTH_OPEN: [UInt8] = [0x00, 0x01]
let AUTH_WPA_PERSONAL: [UInt8] = [0x00, 0x02]
let AUTH_SHARED: [UInt8] = [0x00, 0x04]
let AUTH_WPA_ENTERPRISE: [UInt8] = [0x00, 0x08]
let AUTH_MIXED: [UInt8] = [0x00, 0x0C]
let AUTH_WPA2_ENTERPRISE: [UInt8] = [0x00, 0x10]
let AUTH_WPA2_PERSONAL: [UInt8] = [0x00, 0x20]
let AUTH_WPA_WPA2_PERSONAL: [UInt8] = [0x00, 0x22]
let CRYPT_NONE: [UInt8] = [0x00, 0x01]
let CRYPT_WEP: [UInt8] = [0x00, 0x02]
let CRYPT_TKIP: [UInt8] = [0x00, 0x04]
let CRYPT_AES: [UInt8] = [0x00, 0x08]
let CRYPT_AES_TKIP: [UInt8] = [0x00, 0x0C]
//Values
let idx: [UInt8] = [0x01]
let ssid = "TestWifi"
let ssidBytes: [UInt8] = Array(ssid.utf8)
let password = "Test12345"
let passwordBytes: [UInt8] = Array(password.utf8)
let addr: [UInt8] = [0x11, 0x22, 0x33, 0x44, 0x55, 0x66]
let authBytes: [UInt8] = Array("WPA PSK".utf8)
//Lengths
let Idxlen: [UInt8] = [0x00, 0x01]
var temp = ssid.lengthOfBytes(using: .utf8)
let Namelen: [UInt8] = [UInt8(temp >> 8), UInt8(temp)]
let Authlen: [UInt8] = [0x00, 0x02]
let Cryptlen: [UInt8] = [0x00, 0x02]
temp = password.lengthOfBytes(using: .utf8)
let Keylen: [UInt8] = [UInt8(temp >> 8), UInt8(temp)]
let Maclen: [UInt8] = [0x00, 0x06]
//Packet formation
let id = NETWORK_IDX + Idxlen + idx
let name = NETWORK_NAME + Namelen + ssidBytes
let aut = AUTH_TYPE + Authlen + AUTH_WPA_PERSONAL
let cry = CRYPT_TYPE + Cryptlen + AUTH_MIXED
let key = NETWORK_KEY + Keylen + passwordBytes
let mac = MAC_ADDRESS + Maclen + addr
var payload: [UInt8] = id + name + aut + cry + key + mac
//Prepend Credential Attribute header
let totallen = payload.count
var totallenBytes = [UInt8(totallen >> 8), UInt8(totallen)]
var cred = CREDENTIAL + totallenBytes
payload.insert(contentsOf:cred, at: 0)
print(payload)```
关于ios - 在 Swift 中使用 application/vnd.wfa.wsc 创建 NDEF WiFi 记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57832849/
WSC 的安全性如何? 它是否始终假定它在受信任的环境中运行? 该技术会持续存在还是 MS 有可能很快将其淘汰? 最佳答案 WSC 在调用它们的代码的帐户下运行。我在 IIS 中大量使用它们,在我的案
我即将为用 VBScript 编写的遗留系统启动一个正在工作的迁移项目。它有一个有趣的结构,其中大部分是通过将各种组件编写为“WSC”文件来隔离的,这实际上是一种以类似 COM 的方式公开 VBScr
我无法让此示例 WSC Salesforce 代码正常工作。我缺少什么?我正在尝试为特定帐户创建新事件。我不介意先查询帐户。这看起来很简单,但行不通。 QueryResult queryRes
我正在尝试将一个扩展从 Firefox 移植到 IE。所有扩展的代码都在 JS 中(没有 C++ 组件),所以我想我会重用代码并且只麻烦自己处理它的 mozilla 特定部分(这无疑也是一种折磨,但我
我想在当前可用的服务中使用这个 npm 包。当我运行“npm run start”时,它失败了并且我得到了错误: TypeError: wsc.require is not a function at
我在标签(NFC 切换 wifi)记录类型上写了一条“application/vnd.wfa.wsc”记录。现在我想用扫描标签的给定 Activity 启动我的应用程序。 我做了以下事情: 我通过写标
我正在尝试在 Swift 中创建一个 application/vnd.wfa.wsc 负载。我在这里找到了这篇适用于 Android 的帖子: Creating an NDEF WiFi record
从 Android 5.0.0 开始,您可以长按 WiFi 连接并将该连接写入标签(“写入 NFC 标签”)。您可以在此处找到该操作的来源:WriteWifiConfigToNfcDialog.jav
单元测试项目 Up.UnitTests 在构建期间失败,并出现此构建错误 错误 CS0430:未在/reference 选项中指定外部别名“snh”错误 CS0234:命名空间“snh”中不存在类型或
我是一名优秀的程序员,十分优秀!