UpdateTwinAsync failing - azure-iot-edge

I am trying to update the Module twin of an edge device. I can now retrieve the Device Twin for the module, but I cannot save the updated Desired properties back into the IoT Hub.
var moduleTwin = await registryManager.GetTwinAsync("DeviceId", "ModuleId");
moduleTwin.Properties.Desired["key"] = "value";
var updatedTwin = await registryManager.UpdateTwinAsync("DeviceId", moduleTwin, moduleTwin.ETag)
When this runs, I get the following exception
Where "DeviceId" is the value obscured in red.
I have tried using the device's ETag, but that just updated the device's twin and I have tried using the ModuleId rather then DeviceId and that raises a DeviceNotFoundException.
How do I update the ModuleTwin here?

It seems that registryManager.UpdateTwinAsync can only update device twin. So when you use edge device twin Etag instead of moduleTwin.ETag, the operation will succeed. You can check your edge device, the desired property updated is under device twin not module twin.
Update module twin via Azure Portal seems also not working.
Here is a similar issue about this on Azure IOT SDK for C# you can monitor its update.

Related

ISO14443 - React Native NFC sometimes "Tag connection lost" - only on iOS

Context & Problem:
I’m writing a React Native application which has to communicate with NFC MiFare Ultralight tags. I have NXP NTAG I2C PLUS ISO14443-3 tags.
I’m using the react-native-nfc-manager library for this. On android I didn’t notice any problems just on the iOS side. I’m testing on iOS 13 and 14 and my device is an iPhone 7.
I am able to find and connect to NFC Mifare Ultralight tags (can read and write them too), but in the 75% of the situations I get the following error during the communications:
[CoreNFC] 00000002 803f43f0 -[NFCTagReaderSession transceive:tagUpdate:error:]:771 Error Domain=NFCError Code=100 "Tag connection lost" UserInfo={NSLocalizedDescription=Tag connection lost}
This problem only appears on iOS. Android works fine.
How I communicate:
I added the NDEF and TAG formats to the entitlements file to the …readersession.formats.
I also added value to the info.plist for the Privacy - NFC Scan Usage Description.
I’m requesting NfcTech.MifareIOS tech and calling the NfcManager.sendMifareCommandIOS() method as the library’s MiFare example shows. I’ve tried to use other transmitter methods and requesting other tech types, but in those situations I didn’t even get any responses.
This is how I create the writing commands and how I call my transmit method:
// WRITE COMMAND looks like: [0xA2, Addr, datas]
const writeCommand = [0xa2, offset, data[0], data[1], data[2], data[3]];
const response = await this.transmit(writeCommand);
This is how I create the reading commands:
// FAST_READ COMMAND looks like: [0x3A, StartAddr, EndAddr]
const readCommand = [0x3a, offset, offset + readLength];
And here is my transmit method:
private async transmit(msg: number[]): Promise<number[]> {
...
const cmd = Platform.OS === 'ios' ? NfcManager.sendMifareCommandIOS : NfcManager.transceive;
return await cmd(msg);
}
What I noticed and tried:
I noticed that the iPhone is very sensitive for the positioning. If I hold the device in a certain position I can also achieve 80% success. I noticed too that if I leave the phone on the tag I get this error more often. I got better results when I took away the phone after a communication and then put it back again.
When I added some sleep after the communication for example 100 ms, the communication seemed to be more stable. Because of the number of communications, I can't wait that much. Even if I wait I get the error, but fewer times.
I saw a very similar issue which describes a CRC problem, which appears when you try to send CRC, but that has been automatically added already by the iOS. I’m not sending the CRC (which was the solution in the mentioned issue), so that shouldn't be a problem.
Also saw the following issue with similar problem, but I have another type of tags - ISO-14443 and I'm also able to connect and communicate with the tags which wasn't the case in the mentioned issue.
Tried to invalidate the session after each communication, but didn’t help to stabilize the connection.
Tried with multiple tags (but with the same tag type), but got the same results.
I'd appreciate very much any ideas that could help me solve this problem.
At the end I managed to try out our app on multiple iPhones and the NFC worked properly.
We also found out that our test device is a refurbished unit and we think that maybe that is the problem's cause.

When using NEHotspotConfiguration() to joing a network. Always recieve "unable to join"

I am implementing an APP through Xamarin that will force the iPhone to connect to a specific SSID.
Here is my code
var config = new NEHotspotConfiguration(SSID, Password, isWep: false)
config.JoinOnce = true;
var tcs = new TaskCompletionSource<NSError>();
NEHotspotConfigurationManager.SharedManager.ApplyConfiguration(config, err => tcs.SetResult(err));
There are two test result
Assume the target SSID I want to connect called "SSID-A"
I delete the record of "SSID-A" in the iOS system page. Then deploy this APP to the phone.
I give the correct SSID/Password into the code above.
The system popup a message "Unable to join". Failed to connect to this SSID.
I go to iOS system page. Manually connect to "SSID-A". Check the connection is done.
Then I connect to mobile phone to other SSID. And go back to the APP.
This time. It works.
Why there is a different at here?
What can I do to look more into this problem to solve this?
Thanks!
From applyConfiguration:completionHandler: of apple document, we could see the dicsussion that:
This method attempts to join the network only if it's found nearby. Also, because of the noticeable delay that the Hotspot 2.0 discovery mechanism may incur, the method doesn't attempt to join Hotspot 2.0 networks.
Therefore, Join once seems can not mark sure it works.We could have a try with remove this line, or set false as follows:
config.joinOnce = false;
In addition, it seems a bug in iOS 13 from Apple. You could have a look at this discussion.
In case it helps someone one day I had an issue suddenly start where my device was unable to join a network which has previously been working fine.
To test an error condition I tried connecting to a secure network without adding the passphase to the NEHotspotConfiguration. This attempt to join failed but then subsequently after putting the passphase back in the device wouldn't even display the join request dialog and would just fail with an 'Unable to join' error.
I eventually tried another test phone and this worked just fine so it seemed to be an issue on the device itself. I tried resetting my device's network settings but this made no difference.
The fix was to go into the device's wifi setting, join the network manually, return to my app, attempt to join, disconnect from the network in the device settings, and then forget the network. After that it worked fine on every subsequent attempt.

HomeKit Accessory Protocol Step M4

I'm not sure if anyone has been developing with the HomeKit Accessory Protocol (https://developer.apple.com/homekit/specification/) or without the documentation, but I'm running into an issue with step M4.
I've computed M2 (the server proof) and returned it with the following TLV data format (0601040440[serverproof]). I've written a HomeKit client that returns that M2 is valid. I ran this same client against HAP-NodeJS (https://github.com/KhaosT/HAP-NodeJS/) and an accessory using the HomeKit Accessory Simulator, and they both also return that the M2 is valid. If I return invalid data, the client correctly reports that M2 is invalid.
When connecting with an iOS device, the server closes the connection after I return the M4 response. This is what happens if I modify HAP-NodeJS to return an invalid M2. I've also filed a radar #33200334 because at this point, an invalid M2 should report an error to the user, but the Home app simply closes the connection to the accessory and hangs.
Has anybody done any work with HAP and shed some light on this issue?
My mistake was in the TXT-Record "ff" of the Bonjour service.
After I remove this entry from the records, has the iOS Device my ServerProof accepted and is going to step M5.
PS: I have tried to set the value to 0x01 (not as string) and the pairing process works also.

DefaultPath property of NEProvider Class in iOS

DefaultPath property of NEProvider class in iOS is used to represent current default network path used for connections created by the provider.
I am using this property to notify if interface changes from Wi-Fi to 3G or vice-versa using the KVO method. I am getting notification whenever there is change in interface but sometimes even though there is no change in interface I am getting the notification.
Do anyone face the same problem?
I tried to use Reachability class to detect network interface change but it is not working when VPN is connected.
It is already mentioned in Apple DOC-
NWPath contains the viability status and the properties of the path
that a network connection will take on a device.
For example, if the path status is NWPathStatusSatisfied, then a
connection attempt will be made.
When attached to a specific connection, a path takes all of the
connection parameters into account. For example, if the route for a
connection changes or is removed, the path will reflect that change.
Note that every path is evaluated within the context of the process it
is running in, and may be different across processes.
As you have mentioned you are tracking Wi-Fi to 3G or vice-versa , but there is no type of specific documentation check is the mobile is connected through 3G or WiFI or whatsoever.
This the following NWPathStatus you can track down,so it is quite sure that you are catching a wrong notification.
enum {
NWPathStatusInvalid = 0,
NWPathStatusSatisfied = 1,
NWPathStatusUnsatisfied = 2,
NWPathStatusSatisfiable = 3,
}
;

BlackBerry Push Service return rc=10002, what that means?

when i try to register to the Blackberry push service from the real device i receive this response from their server "rc=10002"and wont register to the service.
what this response means and why im getting this now (the same code was working fine at the same device and network).
Thanks.
From the source code included in the API examples rc == 10002:
The push application id specified is
null or empty or if the push
application with the given id cannot
be found.

Resources