How do I get valid lastActivityTime and cloudToDeviceMessageCount values for an IoTHub device? - azure-iot-hub

When I query the device twins for my active devices, either in code (via the C# SDK or in the Device Explorer), lastActivityTime is always "0001-01-01T00:00:00Z" and cloudToDeviceMessageCount is always 0. Valid fields appear to be deviceId, the etags, status, connectionState, and lastUpdated on the properties metadata fields. Is there additional configuration or provisioning I need to do to obtain the additional information?

We can start to see the Device twins get updated only if we have any status updated from any particular devices, Please see the below images for a detailed steps to demonstrate the device twin updated properties. For example if your device is shutdown or disabled as explained in the below images.
Steps: VS code the easy way.
1) Go to the Azure portal-->IoT Hub -->Device and 'Disable' its connection
2) Go to VS code , right click the device and select 'Get Device Info'
3) You will see the device twin is reported as the status is "Disconnected" and even the 'StatusUpdatedTime and 'LastActivity' are also reported for the first time and will continue to keep reporting if there is an activity on the particular device.
Steps: Device Explorer, the easy way
1) Open the Device Explorer Twin, Messages to Device-->Select your device and send a Message. You can use the VS Code to Get Device info again as showed in the previous step. Here in the below image you can see the "cloudToDeviceMessageCount":1 , keep on sending further messages from Device explorer and check the message count.
More info can be obtained from Understand and use device twins in IoT Hub.
Step: Cloud to device messaging: Azure Portal
Please read more info about Cloud to device Messaging
Step: Using Azure IoT service SDK NuGet package. C# Sample App C2D
Happy Azure IoT Learning

Related

Android Emulator connect external storage Device while running

I have an App that needs to detect, if a USB Storage device is getting mounted. Can i simulate the mounting of an USB Storage Device while the Emulator is already running? This way i can debug the behavior of my app.
As i know, for registering the mounting and unmounting of the USB Storage Device i can use the StorageVolumeCallback(). What do i have to do to write a simple .txt File to that attached USB Storage Device?
Im having trubble to create a StorageManager inside my ViewModel because i do not have access to the Context.
Im thankful for any Tipp related to USB Storage Management at all.
Info:
API Version: 31
IDE: Android Studio
Language: Kotlin
Edit:
So i do not necessarily need to have a external usb drive mounted at startup. If its possible with adb it would be great if i could just forward a usb Pendrive to the running emulator when i need it. Something like adb connectUsbDevice -deviceid=****,vendorid=***
There isn't a .NET library I'm aware of which can do this. However, please refer to this post where the brilliant answer shows how to do this interfacing with the Win 32 API.
How do I disable a system device programmatically?
You'll need a combination of this, and a WMI query to find an attached PnP device of type storage. As a clue:
using (var searcher = new ManagementObjectSearcher(#"SELECT * FROM Win32_USBHub"))
{
collection = searcher.Get();
}
Change Win32_USBHub to the correct class if this isn't giving you what you're looking for.
EDIT: Be warned. If you're disabling storage devices, make sure they're not in use. That's what the "Safely remove USB" option is for in Windows.
Another option, if you don't need to emulate this in code, use a real USB storage device inserted in the system and use PowerShell to get, disable, and enable the device.
The Cmdlets you'll need are:
Get-PnpDevice
Disable-PnpDevice
Enable-PnpDevice

getUserMedia: access system output stream

I know how to access audio input devices via getUserMedia() and route them to the WebAudio API. This works fine for microphones and such. But in my use-case, I would rather like to hook into the audio stream of an output device. The use case is that I want to create a spectrum analyser for audio coming from a digital audio workstation (DAW) running on the same PC.
I tried to enumerate the devices and call getUserMedia() with the device id of an audio device, but the stream returned only showed silence data. The only solution I found so far is to install an audio loopback device (like Soundflower on Macs) to route the DAW's output to and then use this as an input device for getUserMedia(). But this will require the user to install 3rd party software.
Is there any way to hook directly into the audio stream of an output device instead, before it is actually sent to the physical device (speaker or external soundcard)?
This can be achieved using the desktop capture APIs (chrome.desktopCapture.chooseDesktopMedia). An example for chrome is included here

Mobile First Platform v 7.1 cannot register the devices

We have done the installation and configuration of MFP 7.1V with WAS 8.5.5.0 V successfully.Here we are able to access the operation and analytics console and able to add the application (.wlapp files) and adapter files and able to access those application in tab by instantiating an apk files in the tab.
But here the issue we are facing is we are not able to get the devices list in the operation console and analytics and devices tracking in the analytics console.
So essentially I guess the issue is that the applications fail to connect to the server at all. Please edit your question with the full client-side log with the errors.
Until then my suggest is to verify in the generate .plist/.properties file that you are indeed attempting to connect to the correct server. Verify the host, port and context-root values in the files.

USB Mobile Broadband Modem on Windows 10 IoT?

Anyone had experience using a USB Mobile Broadband on Windows IoT with the Raspberry Pi2 already?
I have a Huawei datacard in the Windows IoT and appears as HUAWEI Mobile on connected devices but I'm unable to see the device on the wifimanager.htm admin page.
Don't even appear on the Device Manager list. Is this lack of drivers?
I was looking for a solution too, and I have finally found one. I hope the following will help you!
For the record, I used a Vodafone (Huawei) K5150, "officially" supported and Microsoft verified, according to the hardware compatibility list: https://developer.microsoft.com/en-us/windows/iot/win10/supportedinterfaces. The device was recognized and visible on the portal through an hdmi screen. Anyway, the raspberry couldn't get internet access.
Here is what I did to make it work:
install the key on a common laptop and check the internet access. Windows should see it as a cellular connection by the way.
find the xml file generated by Windows and located under C:\ProgramData\Microsoft\WwanSvc\Profiles. This file is called a profile and is used by Windows to characterize every wireless connection it sees. You can of course create yourself this file from scratch, but it's far more complicated/boring. You can also normally do that with the netsh command and the import or dump sub-command, but it doesn't work for broadband devices.
connect your raspberry to your local network and go to \\[name or IP address]\c$. In my case, it was \\minwinpc\c$. There, find a suitable place to copy the xml file, as well as the bmp file next to it, and don't forget to modify its content to point the right path for the icon (the bmp file).
the next step is super tricky, but highly important: you have to find the subscriber ID for your key. The one saved in the xml file is actually a kind of hash and if you don't set the correct value you'll have an error like
Add Profile Failure: Invalid Profile XML.
connect the key to your raspberry and enter a PSSession with PowerShell (details here: https://developer.microsoft.com/en-us/windows/iot/win10/samples/powershell). Then, use this command: netsh mbn show readyinfo interface="Cellular". The correct interface (in my case it's "Cellular") can be retrieved with the command netsh mbn show interfaces (mbn standing for Mobile Broadband I suppose). The subscriber ID, with other useful information, is displayed and you can copy it the to the xml file on your raspberry.
what's left is the actual profile activation, in two parts: add the newly imported profile and tell the raspberry to connect to it. For that, use the commands netsh mbn add profile interface="Cellular" name="profile.xml" and netsh mbn connect interface="Cellular" connmode=name name=ProfileName.
You mobile broadband key should now be activated and the raspberry should automatically connect to it at start.
Here are the few links that helped me a lot:
export the profile: https://www.experts-exchange.com/questions/28324340/Adding-custom-mobile-broadband-profiles-in-Win-7.html
replace the subscriber ID: https://social.technet.microsoft.com/Forums/office/en-US/7c2d6c77-1974-432b-a439-6e58f9306234/receive-add-profile-failure-invalid-profile-xml-error-when-adding-wwan-profile-windows-7?forum=w7itpronetworking
connect to the raspberry to copy the files: https://developer.microsoft.com/en-us/windows/iot/win10/samples/smb

IpOverUsbSvc error

I have a problem with visual studio window phone 8. In the 'Windows Phone Developer Registration' window I get 'unable to connect to a phone'. The message also says 'For Windows Phone 8 phones make sure that the Windows phone IP Over USB Transport (IpOverUsbSvc) service is running. I followed the instructions on this site and this service is running. I still get the same problem. What can I do?
Delete devices from Device Manager as described here. Additionally I had to remove my Lumia devices from "Other devices". Also try to restart IpOverUsbSvc service.
Ok first it must that your operating system and your SDK have the same language.
second check Are the date and time set correctly on the phone? In SETTINGS | date + time, turn off the Set automatically setting and then retry registration.
if the registration succeed and you have a certificate error or anything wrong then download
the Preview for Developers in your phone and unlock it
Make sure you're using a developer account, not just any old Microsoft account.