2605 views|3 replies

3414

Posts

0

Resources
The OP
 

【NXP IoT Module Review】Light up a cloud lamp [Copy link]

This post was last edited by ljj3166 on 2018-7-7 16:22 Sorry, all viewers, I'll just light up a little bit. In the AWS cloud platform service, terminal devices, such as the NXP IoT Module, exist in the form of shadow. In my personal understanding, whether it is a single board or a terminal application, as long as the certificate and key are correct, they can connect to the shadow and complete the information exchange. Because AWS only provides IoT Core services and does not provide interfaces such as user instruments, to control terminal devices, you also need to write your own application. Given that the core of NXP and AWS's IoT solutions is MQTT and the AWS cloud page access is at a snail's pace, how to implement MQTT specifically, I'm too lazy to delve into the main actions of this product, which are subscription (Subscribe) and publication (Publish). So here we use an MQTT debugging artifact----------MQTT.FX. The parameters and files required for the following operations can be found in this post: 【NXP IoT Module Evaluation] IoT development environment construction Click the small gear to enter the connection configuration interface Click the "+" sign in the lower left corner to add a connection configuration. Fill in the URL of the thing shadow in Broker Address. Broker Port is determined in the code directory lpc54018iotmodule_aws_shadow_wifi_qspi_xip\amazon-freertos\include\aws_clientcredential.h
  1. /* * Port number the MQTT broker is using. */ #define clientcredentialMQTT_BROKER_PORT 8883
复制代码
Well, fill in 8883. Client ID can be filled in or not. If you want to fill it in, it is best to fill in the name of the shadow thing. The original poster is NXPIoTBoard. Next, enter the SSL/TLS page Enable SSL/TTL and select Self signed certificates, among which CA File is the root certificate file required for secure connection to AWS, attached here directly: VeriSign-Class 3-Public-Primary-Certification-Authority-G5.pem (1.72 KB, downloads: 0) Client Certificate File is the connection certificate Client Key File is the private key. Load them separately and finally check PEM Formatted. The connection configuration is set. Return to the main page and click Connect. You can find that you can connect to your shadow Thing normally. Note that you must click scan in the lower left corner. All pushed Topics are scanned here. When you connect to the board, you will find that subscription and push start working. The lower left corner shows the subscription and push Topics, and the lower right corner is the specific payload. I went to AWS specifically to check the Topic. The format reserved by AWS IoT Core is basically the same as the Topic scanned by the software. In the aws_shadow.c file of the engineering code, a similar string has actually been defined. Here the host defines a LED topic by himself. #define shadowTOPIC_OPERATION_LED "led" #define shadowTOPIC_UPDATE_LED shadowTOPIC_PREFIX shadowTOPIC_OPERATION_LED Follow a few lines
  1. #define shadowLED_JSON \ "{" \ ""state":{" \ ""desired":{" \ ""LEDstate":"%s"" \ "}" \ "}," \ ""clientToken ": "token-%d"" \ "}" static uint32_t prvGenerateLEDJSON( ShadowQueueData_t * const pxShadowQueueData, uint8_t ucBulbState ) { /* Map cBulbState to strings. */ static const char * const pLED[ 2 ] = { "0", "1" }; /* Generate JSON. */ return ( uint32_t ) snprintf ( ( char * ) pxShadowQueueData->pcUpdateBuffer, shadowDemoBUFFER_LENGTH, shadowLED_JSON, pLED[ ucBulbState ], ( int ) xTaskGetTickCount() ); } ShadowReturnCode_t SHADOW_Led( ShadowClientHandle_t xShadowClientHandle, ShadowOperationParams_t * const pxUpdateParams,TickType_t xTimeoutTicks ) { ShadowOperationCallParams_t xUpdateCallParams; configASSERT( ( ( BaseType_t ) xShadowClientHandle >= 0 && ( BaseType_t ) xShadowClientHandle < shadowMAX_CLIENTS ) ); /*lint !e923 Safe cast from pointer handle. */ configASSERT( ( pxUpdateParams != NULL ) ); configASSERT( ( pxUpdateParams->pcThingName != NULL ) ); configASSERT( ( pxUpdateParams->pcData != NULL ) ); configASSERT( ( pxUpdateParams->xQoS == eMQTTQoS0 || pxUpdateParams->xQoS == eMQTTQoS1 ) ); xUpdateCallParams. xShadowClientID = (BaseType_t) xShadowClientHandle; /*lint !e923 Safe cast from pointer handle. */ xUpdateCallParams.xOperationName = eShadowOperationUpdate; xUpdateCallParams.pcOperationName = shadowTOPIC_OPERATION_UPDATE; s->pcData; xUpdateCallParams.ulPublishMessageLength = pxUpdateParams->ulDataLength ; xUpdateCallParams.pxOperationParams = ( ShadowOperationParams_t * ) pxUpdateParams; xUpdateCallParams.xTimeoutTicks = xTimeoutTicks; return prvShadowOperation( &xUpdateCallParams ); }
复制代码
Crawling again, we can find that the software has been able to capture the newly defined LED Topic and the json content can be recognized normally. The next step to turn on the light is to configure the peripheral operation string and then I won't go into details here. After processing the code for the single board, you need to configure the outbound and inbound policies on the AWS cloud. You need to create a new policy and bind it to the certificate. The new policy is NXPLedPolicy. : The red area needs to fill in the policy ARN identifier, which is the red area in the figure below Note that the above policy may not match the topic of the single board. The correct one was accidentally deleted by the OP. However, the process and the required information are similar. I am too lazy to go through the details here. Then, in Security--Certificate--Additional Policies, bind the NXPLedPolicy policy. [attach]362865[ /attach] | | After the above operations, I was sweating profusely... Operate on the Pulish page of the software Directly post a GIF [attach]362862[/ [attach] OK, the lights are on... I still have a baseboard peripheral that I don't have the energy to tinker with... Who wants it? This content was provided by a netizen from EEWORLD forum Original by ljj3166. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source.xTimeoutTicks = xTimeoutTicks; return prvShadowOperation( &xUpdateCallParams ); } [/code] Crawl again You can find that the software has been able to capture the newly defined LED Topic and the json content can be recognized normally. The next step to turn on the light is to configure the peripheral operation operation string and then pull up and down the IO port. I will not go into details here. After processing the code of the single board, you need to configure the outbound and inbound policies on the AWS cloud. You need to create a new policy and bind it to the certificate. The newly created policy---NXPLedPolicy: The red area needs to fill in the policy ARN identifier, which is the red area in the figure below Note that the above policy may not match the topic of the single board. The correct one was accidentally deleted by the original poster. However, the process and the things that need to be filled in are similar, so I am too lazy to go through it again here. Then bind the NXPLedPolicy policy in Security--Certificate--Additional Policies and it will be ok. | | After the above operations, I was sweating profusely... Operate on the Pulish page of the software Here is a gif Okay, the light is on... There is still a peripheral device of the baseboard that I haven’t built and I don’t have the energy to tinker with... Who will take it? This content was originally created by EEWORLD forum user ljj3166. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the sourcexTimeoutTicks = xTimeoutTicks; return prvShadowOperation( &xUpdateCallParams ); } [/code] Crawl again You can find that the software has been able to capture the newly defined LED Topic and the json content can be recognized normally. The next step to turn on the light is to configure the peripheral operation operation string and then pull up and down the IO port. I will not go into details here. After processing the code of the single board, you need to configure the outbound and inbound policies on the AWS cloud. You need to create a new policy and bind it to the certificate. The newly created policy---NXPLedPolicy: The red area needs to fill in the policy ARN identifier, which is the red area in the figure below Note that the above policy may not match the topic of the single board. The correct one was accidentally deleted by the original poster. However, the process and the things that need to be filled in are similar, so I am too lazy to go through it again here. Then bind the NXPLedPolicy policy in Security--Certificate--Additional Policies and it will be ok. | | After the above operations, I was sweating profusely... Operate on the Pulish page of the software Here is a gif Okay, the light is on... There is still a peripheral device of the baseboard that I haven’t built and I don’t have the energy to tinker with... Who will take it? This content was originally created by EEWORLD forum user ljj3166. If you want to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source

This post is from NXP MCU

Latest reply

Thumbs up!!  Details Published on 2018-8-15 11:00
Personal signature

So TM what......?

 


3414

Posts

0

Resources
2
 
Eliminate 0 replies, everyone is responsible
This post is from NXP MCU
 
Personal signature

So TM what......?

 

 

13

Posts

2

Resources
3
 
good
This post is from NXP MCU
 
 
 

34

Posts

0

Resources
4
 
Thumbs up!!
This post is from NXP MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list