Azure IOT Central - Cloud to Device messages using MQTT - azure-iot-hub

My IOT Device is connected to IOT central and am able to receive data through export option.
Now i want to send some command to My device,
For example,
Below json data it is expecting to send heartbeat of device on subscribed URL'devices/....ba50621/messages/devicebound/#'
{ "action": "heartBeat",
"requestId": "b2c3d4e5-3424-4dca-32dc-12b73290cfed"
}
i created service application by refering below links to send Cloud to device message,
Stackoverlow ans and
Sample app
used connection string as,
"HostName=asdasdas.azure-devices.net;DeviceId=asdasdasda50621;SharedAccessKey=nXmyveEPrV....pmo9jULvDtik="
This connection string was received when device got register though dps. i used this on service application to connect. i dont know whether this correct.
When application tried to send message, i got unauthorized error.
In the documentation of above link says to get connection string from shared access policy of IOT hub. but i am using iot central and used above connection string.
Kindl help me fix it.

Cloud to device messaging works a bit different in IoT Central than a plain IoT Hub. Instead of connecting the service client to your IoT Hub, you have to use the IoT Central REST API.
You can either send commands to your device or update a property. The complete documentation including samples are here. You can find the documentation to send commands to your devices here.

In the case when your IoTC App is NOT a legacy application, you can use a preview IoTC App (which is a CapabilityModel driven model type) with the REST APIs support for calling your device. Currently preview version doesn't have a feature what you are trying achieved, such as sending a C2D message to the device.
The IoTC preview supports only calling the device method - Execute Command.
The following screen snippets demonstrated this feature. For this example, I am using my Azure IoT Hub Tester, where the virtual devices are using the MQTT protocol directly to the underlying IoT Hub of the IoT Central App.
I have created a free IoT Central App with the AzureKit ESP32 template, registered and provisioned for device1 and connected from the Azure IoT Hub Tester:
Showing a command echo PnP model:
Invoking a command echo by REST POST call. Note, that the Authorization sastoken must be created in the Administration/API tokens page.
The device1 received the direct call and than published its response (note, that this screen was not snipped for its short response time limit). The following screen snippet shows a complete sync REST call with the device1. Note, that this preview version didn't handle the response payload based on the mentioned document and PnP model.
Finally, this screen snippet shows the history of this command action via the REST:
Note, that there is also missing the response object from the device like is described in the CapabilityModel schema.
UPDATE
I have added the missing screen snippet on the device side when the method echo has been invoked:
As you can see the above picture, the device received the REST POST payload and its published response back to the invoker based on the PnP model schema.
UPDATE 2
The following screen snippets demonstrated invoking a command upgrade for device4. Note, that the device4 is a PnP device created from the template SmartConnect FM-201 IoT Gateway.
The device4 received a message on the direct method upgrade:
The device4 sent the response back to the invoker and IoTC app. The following picture shows its history:
Notice again, there is missing a response object in the REST response and also in the IoTC App. I hope, this is a bug in this preview version and it will fix it soon to follow up the CapabilityModel schema.

Related

APNS handle obtained by Expo in React Native is incorrect

EXPO SDK Version: 42.0.01
Developing for: iOS
Our goal: successfully send a test notification from Test Send tool in Azure Notification Hub to a registered physical iPhone which is running a local instance of an EXPO app.
Progress: we're able to successfully register a physical iPhone with Azure Notification Hub without using a 3rd party library. We can see that registration in the Hub.
Issues: when using the Azure's Test Send tool we're getting an error "The Push Notification System handle for the registration is invalid" and the test notification does not get delivered.
Debugging:
we're using EXPO's Notifications.getDevicePushTokenAsync() API to obtain the push token.
Azure support team analysed the logs and concluded that the problem is the PNS handle i.e. Apple's ID of the phone registered for notifications.
the phone's PNS handle remains the same at all times.
by using "expo credentials:manager" I've added a new Push Notification Key using KeyID, TeamID and .p8 certificate - the PNS handle didn't change after doing that and notifications were failing too.
I haven't found any tools to validate the APNS handle. I'm currently awaiting a .p12 certificate from our corporate team to test notifications by using https://pushtry.com/.
How do we validate the APNS handle and if found that it's invalid - how do we cycle it / request another?
The PNS Handle from APNs does not change that often as it is tied to the device and app installation. See this answer for more details Does the APNS device token ever change, once created?

How to get live stream sharable CDN link using agora-sdk ng

Created angular project using agora sdk ng
tried to push my live stream using agora it throw me berlow error
reason: "Publish error on rtmp-publish"
status: 32
type: "liveStreamingFailed"
url: "rtmp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov"
Agular side code:
this.client.startLiveStreaming("rtmp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov",false);
Please help on my above issue.
Thanks in advance
The startLiveStreaming method is meant to push the Agora stream to an extertnal RTMP server, such as pushing your stream to YouTube Live or Twitch.
To inject media from an RTMP url, you should use addInjectStreamUrl(API reference)
From the documentation:
Injects an online media stream to a live-broadcast channel.
After you call this method, the server pulls the online stream and
injects it into a live-broadcast channel. This is applicable to
scenarios where all audience members in the channel can watch a live
show and interact with each other. See Inject Online Media Stream for
details.
If the online media stream is injected successfully, this stream is
added to the channel, and all users in the channel receive the
AgoraRTCClient.on("user-published") and
AgoraRTCClient.on("user-joined") callbacks with the uid 666.

Video call between an intercom device (SIP) and a web client (WebRTC)

I have been reading a lot of SIP/WebRTC documentation and it is not clear to me whether a video call between an intercom device (SIP) and a web client (WebRTC) can be established.
I have researched and played with various VoIP server/frameworks like OverSIP, Asterisk, Kamailio, JSSIP, PJSIP, FreeSwitch, dratchio ... and all I have got is to receive the SIP device call in the server.
The basic flow for the PoC would be as follows:
SIP device (video door entry) initiates call to the server
Server receive the call
The client can contest the videocall using a web page.
The complete flow would be as follows (always the same flow):
SIP device (video door entry) initiates call to the server
Server determine the destination client
Server make a temporal webpage to contest the videocall
Server sends the URL using a notification to client's mobile device (or clients mobiles, in plural)
The mobile receive the notification and open the web page showing the video call
The customer can answer the video call from the web
It's possible? Is there an example or tutorial for help?
Thanks!

Gcm with appodeal

I am using gcm with appodeal in my app and when I am sending the push notification the for the first push was successful but phone is not receiving the notification and after that error is there while sending push that device is not register. What to do in this situation please help me.
Is it iOS or Android ? I had the exact same issue just yesterday with iOS and all I had to was to create a development provisioning profile and set it up properly in xCode. I hope that helps you.
I think for you to verify that your app can send and receive messages, client apps must register with GCM.
To register with GCM:
1.The client app obtains a registration token using the Instance ID API. The call to this API must have the authorized entity set to your app server's sender ID, and the scope set to the appropriate value for GCM (depending on your platform). Refer to the API reference for full detail on this API.
2.The client app passes the registration token to the app server.
3. The app server saves the registration token and acknowledges to the client app that the process completed successfully.
This thread may also provide further insight as to why you are receiving the device not registered error.

Can't receive toast notification in windows phone 8

I'm having problems receiving toast notifications for a Windows Phone 8 application. I did all the steps required:
For the client side, I did this:
Get the channelUri from MPNS
Open the channel
Bind to toast notifications
For the server side, I did this:
Server is written in PHP using this code
Hard-coded the Channel Uri I got in the client app into the PHP code (for testing purposes)
However, when I send the notification from the server, the phone doesn't seem to receive it. Everything runs correctly on the server side and the curl library loads without problems.
I got this!
The problem was in my constructor of the channel. I was doing this to create a new channel:
httpChannel = new HttpNotificationChannel("MyChannel","www.foobar.com");
This constructor should only be called in case of "Authenticated Mode" of push notifications, which requires registering your website and having a certificate.
Obviously, this wasn't my case as I was just testing the push system.
The solution was to create the channel using this:
httpChannel = new HttpNotificationChannel("MyChannel");
It's so misleading as the the official documentation of Windows Phone didn't mention this.