Questions tagged with Internet of Things (IoT)

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

1
answers
0
votes
10
views
profile picture
asked 17 days ago

Connect to AWS IoT/MQTT using Azure NetXDuo

Does anyone have experience with connecting to AWS IoT using Azure RTOS NetXDuo? I have successfully connected to Azure IoT and Mosquitto public broker. The problem I think is I'm using certificates in the wrong way This is an example of when I'm successfully connected to mosquitto: it uses only root_ca certificate without username/password. ``` #define HOST_NAME "test.mosquitto.org" #define SERVER_NAME "test.mosquitto.org" #define DEVICE_ID "nxpevkboard" #define SERVER_PORT 8883 #define PUBLISH_TOPIC "devices/%s/test/me" #define SUBSCRIBE_TOPIC "devices/%s/notice/me" for (i = 0; i < sizeof(threadx_tls_remote_certificate) / sizeof(NX_SECURE_X509_CERT); i++) { /* Need to allocate space for the certificate coming in from the remote host. */ nx_secure_tls_remote_certificate_allocate(tls_session, &threadx_tls_remote_certificate[i], threadx_tls_remote_cert_buffer[i], sizeof(threadx_tls_remote_cert_buffer[i])); } /* Add a CA Certificate to our trusted store for verifying incoming server certificates. */ status = nx_secure_x509_certificate_initialize(trusted_certificate, mosqitto_root_ca, sizeof(mosqitto_root_ca), NX_NULL, 0, NX_NULL, 0, NX_SECURE_X509_KEY_TYPE_NONE); status = nx_secure_tls_trusted_certificate_add(tls_session, trusted_certificate); ``` AWS provides one more certificate and private key. I tried to include both certificates with provided private_key. API returned success status but later client can't connect to the host, so maybe I have a mistake in host or servername. ``` #define HOST_NAME "xxxx.iot.us-west-2.amazonaws.com" #define SERVER_NAME "xxxx.iot.us-west-2.amazonaws.com" #define DEVICE_ID "nxpevkboard" #define SERVER_PORT 8883 #define PUBLISH_TOPIC "devices/%s/test/me" #define SUBSCRIBE_TOPIC "devices/%s/notice/me" for (i = 0; i < sizeof(threadx_tls_remote_certificate) / sizeof(NX_SECURE_X509_CERT); i++) { /* Need to allocate space for the certificate coming in from the remote host. */ nx_secure_tls_remote_certificate_allocate(tls_session, &threadx_tls_remote_certificate[i], threadx_tls_remote_cert_buffer[i], sizeof(threadx_tls_remote_cert_buffer[i])); } /* This should be local cert i think. */ status = nx_secure_x509_certificate_initialize(certificate, amazon_cert, sizeof(amazon_cert), NX_NULL, 0, private_key, sizeof(private_key), NX_SECURE_X509_KEY_TYPE_RSA_PKCS1_DER); status = nx_secure_tls_local_certificate_add(tls_session, certificate); /* Add a CA Certificate to our trusted store for verifying incoming server certificates. */ status = nx_secure_x509_certificate_initialize(trusted_certificate, amazon_root_ca_cert, sizeof(amazon_root_ca_cert), NX_NULL, 0, private_key, sizeof(private_key), NX_SECURE_X509_KEY_TYPE_RSA_PKCS1_DER); status = nx_secure_tls_trusted_certificate_add(tls_session, trusted_certificate); ```
1
answers
0
votes
21
views
Brjk
asked 23 days ago

How to use GreenGrass MQTT to trigger a script

My testing has hit a number of roadblocks: 1. I often run into an issue where my GG device stops accepting any new component commands including deployments from the console. The console will report all is well, but the instance does not show the updated component list for example. This can be solved easily by restarting the instance and running the commands again or redeploying, although I do not know why this occurs, this will happen after about 1-2 hours of constant use on a t3.large Ubuntu Cloud9 instance. It seems to occur specifically with the Publisher and Subscriber components running but enough work with any components will cause logs to start failing to appear in the /greengrass/v2/logs file and new commands to be essentially ignored. This is hard to catch and harder to debug due to the lack of new log files. 2. Just trying to test the Stream Manager component has proven to be almost impossible and my test case (which I've gotten to work just a week ago) no longer runs correctly and I have no idea how to fix it or if I'm looking at the incorrect logs. I've been running the Custom Component tutorial here: https://docs.aws.amazon.com/greengrass/v2/developerguide/use-stream-manager-in-custom-components.html This is under the "Define component recipes that use stream manager" > "Use the Stream Manager SDK for Python" > https://github.com/aws-greengrass/aws-greengrass-stream-manager-sdk-python/blob/main/samples/stream_manager_s3.py I will include the logs in a response below 3. Finally, I don't see any documentation on how to trigger a component using MQTT. I've tried importing a Lambda which has the option to be triggered by the local topic but haven't been able to test it due to the above. Any documentation on how to subscribe to a topic and run a script on the GG Core device when a message comes through from a client device (similar to an SNS topic triggering a Lambda) would be helpful. PS. I did find some stuff for V1 of GG but I'm specifically looking for V2.
2
answers
0
votes
35
views
asked 23 days ago

Greengrass - Stream Manager - Failed to establish connection with the server

Hi there, I've installed the stream manager via pip, also installed the stream manager component via AWS console and everything looks healthy. I am trying to run these samples from github: https://github.com/aws-greengrass/aws-greengrass-stream-manager-sdk-python/tree/main/samples and I am getting this error message (using sudo): ``` ERROR:StreamManagerClient:Received ConnectResponse with unexpected status ResponseStatusCode.Unauthorized. ERROR:root:Exception while running Traceback (most recent call last): File "s3.py", line 41, in main client = StreamManagerClient() File "/usr/local/lib/python3.8/dist-packages/stream_manager-1.1.1-py3.8.egg/stream_manager/streammanagerclient.py", line 114, in __init__ UtilInternal.sync(self.__connect(), loop=self.__loop) File "/usr/local/lib/python3.8/dist-packages/stream_manager-1.1.1-py3.8.egg/stream_manager/utilinternal.py", line 39, in sync return asyncio.run_coroutine_threadsafe(coro, loop=loop).result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 444, in result return self.__get_result() File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result raise self._exception File "/usr/local/lib/python3.8/dist-packages/stream_manager-1.1.1-py3.8.egg/stream_manager/streammanagerclient.py", line 152, in __connect await asyncio.wait_for(self.__connect_request_response(), timeout=self.request_timeout) File "/usr/lib/python3.8/asyncio/tasks.py", line 494, in wait_for return fut.result() File "/usr/local/lib/python3.8/dist-packages/stream_manager-1.1.1-py3.8.egg/stream_manager/streammanagerclient.py", line 309, in __connect_request_response raise ConnectFailedException("Failed to establish connection with the server") stream_manager.exceptions.ConnectFailedException: Failed to establish connection with the server ``` So the error says that if failed to establish a connection with the server, but I am not sure what server is it referring to? DId I miss a step somewhere? Cheers, Mark
0
answers
0
votes
27
views
asked a month ago

Communicate sockets with components

Hello. I deployed component to Raspberry Pi with AWS IoT Greengrass. The Raspberry pi is in normal condition. The deployment status of the components is also normal. But I have an error. I set it as an artifact to the file I uploaded on the S3 bucket. My artifact is a file for socket communication. This is what I think. 1. Deploy components in AWS IoT Greengrass. 2. When the deployment is completed, the server file for socket communication is executed. 3. If I run a client file on my computer, I can connect to each other and communicate with each other. 4. Then, another file in the artifact, the face recognition file, can be executed to make an inference. But I have an error here. Socket communication seems to be connected. However, the print statement that the socket was opened does not appear in the log. So I'm curious. Was it wrong to connect socket communication with components? I'm confused. Because if I run the temperature and humidity measurement file instead of the face recognition file in number 4 above, it runs well! Strangely, the face recognition function does not work. Is it because face recognition takes a long time? Then can I fix this by modifying the components? I don't know if it's a component problem or a socket communication problem. I always look forward to your reply. This is my Raspberry Pi's log. <My Component's Log> 2022-11-07T11:19:51.555Z [INFO] (pool-2-thread-20) com.james.socket: shell-runner-start. {scriptName=services.com.james.socket.lifecycle.run.script, serviceName=com.james.socket, currentState=STARTING, command=["cd /home/pi&&. pracvenv/bin/activate&&cd socketserve&&python3 socketserver.py"]} 2022-11-07T11:21:49.203Z [WARN] (Copier) com.james.socket: stderr. /home/pi/pracvenv/lib/python3.7/site-packages/h5py/__init__.py:40: UserWarning: h5py is running against HDF5 1.10.6 when it was built against 1.10.4, this may cause problems. {scriptName=services.com.james.socket.lifecycle.run.script, serviceName=com.james.socket, currentState=RUNNING} 2022-11-07T11:21:49.204Z [WARN] (Copier) com.james.socket: stderr. '{0}.{1}.{2}'.format(*version.hdf5_built_version_tuple). {scriptName=services.com.james.socket.lifecycle.run.script, serviceName=com.james.socket, currentState=RUNNING} 2022-11-07T11:21:49.205Z [WARN] (Copier) com.james.socket: stderr. WARNING:tensorflow:No training configuration found in the save file, so the model was *not* compiled. Compile it manually.. {scriptName=services.com.james.socket.lifecycle.run.script, serviceName=com.james.socket, currentState=RUNNING} <Greengrass Log> 2022-11-07T11:19:59.699Z [INFO] (pool-2-thread-10) com.aws.greengrass.deployment.DeploymentDirectoryManager: Clean up link to earlier deployment. {link=/greengrass/v2/deployments/previous-success} 2022-11-07T11:19:59.972Z [INFO] (Thread-4) com.aws.greengrass.deployment.IotJobsHelper: Received empty jobs in notification . {ThingName=Raspberrypi4} 2022-11-07T11:34:35.021Z [WARN] (Thread-4) com.aws.greengrass.mqttclient.AwsIotMqttClient: Connection interrupted. {clientId=Raspberrypi4, error=The connection was closed unexpectedly.} 2022-11-07T11:34:35.260Z [INFO] (Thread-4) com.aws.greengrass.mqttclient.AwsIotMqttClient: Connection resumed. {clientId=Raspberrypi4, sessionPresent=true} 2022-11-07T11:34:35.272Z [INFO] (Thread-4) com.aws.greengrass.status.FleetStatusService: fss-status-update-published. Status update published to FSS. {trigger=RECONNECT, serviceName=FleetStatusService, currentState=RUNNING} 2022-11-07T11:34:35.299Z [INFO] (Thread-4) com.aws.greengrass.deployment.IotJobsHelper: No deployment job found. {ThingName=Raspberrypi4} 2022-11-07T11:45:08.486Z [WARN] (Thread-4) com.aws.greengrass.mqttclient.AwsIotMqttClient: Connection interrupted. {clientId=Raspberrypi4, error=The connection was closed unexpectedly.} 2022-11-07T11:45:10.725Z [INFO] (Thread-4) com.aws.greengrass.mqttclient.AwsIotMqttClient: Connection resumed. {clientId=Raspberrypi4, sessionPresent=true} 2022-11-07T11:45:10.728Z [INFO] (Thread-4) com.aws.greengrass.status.FleetStatusService: fss-status-update-published. Status update published to FSS. {trigger=RECONNECT, serviceName=FleetStatusService, currentState=RUNNING} 2022-11-07T11:45:10.767Z [INFO] (Thread-4) com.aws.greengrass.deployment.IotJobsHelper: No deployment job found. {ThingName=Raspberrypi4} Thank you
0
answers
0
votes
19
views
hyorim
asked a month ago