Is it possible to pair with device constant pair key using core bluetooth - iphone

In my iPhone application I would like to communicate with a firmware device. During a connection they can to ask for a pairing key but they said they are not having provision to provide what is the key to enter.
In this situation USP(User Smart Phone) never knows the key to enter. What shall we do to communicate with device ?

they said they are not having provision to provide what is the key to enter
I'm not sure I completely understand this sentence but if the user is given a device that has a specific pin/key, then that has to be documented somewhere for them. This is the same situation as it is with a SIM card's PIN. That code is set by the manufacturer and the user gets to know it when she buys the card. If the code is the same for all devices, then you can add it to your application and show it to the user in some way.
The iPhone application cannot dismiss or enter any value in the pairing dialog, this is sure.

Related

How to make sure user has bought some device?

I am currently working on a project, where I have hardware device with some sensors etc., and web application, that can show the data to the user, and gives user some control over device.
One user can have many devices, so I need to make some sort of system, where user can add device to his account. And here is the part, where I have encountered an issue.
How can I know, that user has bought (or basically just owns) a device, that can be used with application?
My first thought was: Ok, just add some kind of key to each device, and tell the user to provide this, when they add device. But then I thought - how make sure that key is correct?
Should I make collections in my DB, where all proper keys are stored, check if key provided by user exists, remove key from DB and allow user to add device?
I am using:
MongoDB
Express.js
Mongoose,
to create my API. Do you have any suggestions?
Thanks for your time, and I wish you nice day :)
You should make a table of devices in your database.
Then ask the user to add device id,
then check
if user deviceid exists in devices table

Core Bluetooth: Cannot get iPhone (the central) and Mac (the peripheral) to pair

I am developing an iPhone application and a Mac application that communicate with each other via Bluetooth LE. The iPhone is the central, and the Mac is the peripheral. I would like the iPhone application to be able to reconnect to the Mac application after a relaunch. Therefore, I save the UUID of the peripheral representing the Mac in NSUserDefaults, and then when the iPhone app launches, I call -[CBCentralManager retrievePeripheralsWithIdentifiers:], passing in the UUID. Although this method returns the peripheral, when I call -[CBCentralManager connectPeripheral:options:], the iPhone never reconnects to the Mac. According to this SO post, the problem is that the two devices need to be paired so that the UUID of the Mac is persistent. This brings me to my problem. I cannot for the life of me get the iPhone and the Mac to pair. According to this page of the Core Bluetooth Programming Guide, the way to require a paired connection is for the peripheral to set the characteristic's properties and permissions to the appropriate values. I quote:
You can ensure that only trusted devices have access to sensitive characteristic values by setting the appropriate characteristic properties and permissions. To continue the example above, to allow only trusted devices to retrieve a member’s email address, set the appropriate characteristic’s properties and permissions, like this:
emailCharacteristic = [[CBMutableCharacteristic alloc]
initWithType:emailCharacteristicUUID
properties:CBCharacteristicPropertyRead
| CBCharacteristicPropertyNotifyEncryptionRequired
value:nil permissions:CBAttributePermissionsReadEncryptionRequired];
However, this does not work. Even when I set the correct permissions and properties for the characteristic, the iPhone can still read/write to it without a pairing dialog being displayed. Elsewhere I am told that the way to initiate pairing is for the peripheral to reject a read/write request with an insufficient authentication error. According to this post,
To pair, you need to respond to a write request with an insufficient authentication error. For example, for an iOS peripheral you would write something like:
- (void)peripheralManager:(CBPeripheralManager *)peripheralManager didReceiveWriteRequests:(NSArray *)requests {
...
[peripheralManager respondToRequest:request withResult:CBATTErrorInsufficientAuthentication];
...
}
But this still doesn't work! When the Mac rejects the write request with an insufficient authentication error, the iPhone receives a -[CBPeripheralDelegate peripheral:didWriteValueForCharacteristic:error:] callback with an error that says, "Authentication is insufficient." No pairing dialog. I have no idea what to do and am considering dropping Core Bluetooth altogether if I cannot get this to work. If you have any idea how to get this to work, please let me know.
From Apple DTS:
"I have checked with other engineers here and we don’t believe that the pairing popup is possible between two iOS devices, but an iOS device and a BLE peripheral."
So, pairing popup happens only between a iOS/Mac app and a peripheral. rdar time.

External Device reports no Protocol

I have an app that I have been working on and I am now at the point that I want to integrate some interaction with an external device via the dock connector. The device that I am using (the iDive 300) conforms to the Made For iPod program. I have written a separate simple app based on the EADemo code to gather information about the device. However, when I run this app the iDive reports nothing for the Name, Serial Number, Firmware, etc and also says that no protocols were found. I know this simple app is working correctly because I have connected to several other external devices and the Name, serial number, etc is populated for each device.
The other odd thing is that the iDive seems to work properly when plugged into my iPhone 4 (i.e. it will increase the volume and play songs and videos found on my iPhone via the buttons on the device). Shouldn't this mean that some protocol is in place for this device to communicate with the iPhone? Is it all possible for me to read data from this device (e.g. capture when the 'play','menu', or other buttons are pressed) if I don't know the protocol?
I am completely new to the External Accessories framework and any help is appreciated!
You should autopsy the app that is associated with iDive. In its info.plist, there should be a key:
UISupportedExternalAccessoryProtocols
whose value is an array(See this for the formal definition), and within it lies a string whose value looks like a reversed domain name, as the device protocol.
You should edit your Info.plist, add the key('Supported external accessory protocols' in plain English) for an array, put in the protocol as its item.
There's no guarantee that an accessory actually uses EA. It may communicate using the protocols defined by Apple.
EA is only necessary if you want to communicate using your own proprietary protocol.
Check the EADemo example from Apple... If it doesn't show up in the demo app, it's not EA.

Can I tell if the iPhone has a passcode?

I'm developing an application that asks for a PIN when you start it. That's not great, but I can live with it. The problem is I'm being asked to ask for the PIN each time the phone wakes from sleep, too. Combined with the OS asking for its passcode, it's too much.
Is there any legitimate way to detect if the phone has a passcode required for waking, so I can skip requiring a PIN in this case? I don't want to know the PIN and I don't actually care if it was locked (for instance, if the phone was asleep very briefly), I just want to know that the data is in some way "protected."
For AppStore or not? If the former, no way.
In 3.x, the passcode is stored on the keychain, that means you have to get into the SpringBoard process to determine whether a passcode exists and nonempty. If you are in SpringBoard, calling -[SBAwayController isPasswordProtected] will determine if the device has passcode.
I created a very ugly workaround for this same issue.

geo location and blocking access to my app on iPhone

I am working on a radio player for iPhone.
What I need is to provide my position before playing stream.
I am thinking of using CoreLocation, it's ok, but how to determine geo position if user does not allow CoreLocation when asked ?
What would be the best way to determine the position of the iPhone?
I was thinking of getting IP address, but it could be an address from another country. For exemple, user has an iPhone account in United States, and is using my application in 3G in Canada, IP address will be provided by his cell carrier right ?
So I was wondering how to get cell carrier name, without success... using a private framework is not possible.
I am waiting for your great suggestions!
thierry
I would just use core location. If for whatever reason the user declines the core location popup, then just prompt them to enter their location manually (e.g. choose country and city).
You could use the IP address, but then you run into other problems as well (for instance if they are using WiFi on their iPhone or are on an iPod touch.
I think this is not allowed, and by design. If the user doesn't want your app to know where they are, why do you think you have the right to ignore their wishes?