CBPeripheral name is sometimes null

后端 未结 2 1326
别那么骄傲
别那么骄傲 2021-02-14 11:20

I\'m working on developing an app to communicate with a Bluetooth LE peripheral. The peripheral I am testing with at the moment is one of these. The interesting thing is, some

2条回答
  •  青春惊慌失措
    2021-02-14 11:37

    If you get the name from the advertisingData NSDictionary it will always be the name that is in the advertising packet sent by the peripheral.

    However, if you read the name property of a CBPeripheral object, that name may vary. We try to provide the best name know to us at the time. If we have not yet connected to the peripheral, we will provided the name from the advertising packet. If a connection to the peripheral has been made in the past, we will have read the GAP name. We consider the GAP name to be a 'better' name than what is in the advertising packet (due to the size constraints of the advertising packet).

提交回复
热议问题