Pelion Device Ready example for Advantech WISE-1570 (MTB_ADV_WISE_1570)
Revision 0:2b6d1f2f42fa, committed 2019-01-25
- Comitter:
- Juho Eskeli
- Date:
- Fri Jan 25 14:38:52 2019 +0200
- Child:
- 1:75f7384f9a0b
- Commit message:
- Pelion Device Ready example for MTB_ADV_WISE_1570
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LICENSE.txt Fri Jan 25 14:38:52 2019 +0200 @@ -0,0 +1,165 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and +distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright +owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities +that control, are controlled by, or are under common control with that entity. +For the purposes of this definition, "control" means (i) the power, direct or +indirect, to cause the direction or management of such entity, whether by +contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the +outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising +permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including +but not limited to software source code, documentation source, and configuration +files. + +"Object" form shall mean any form resulting from mechanical transformation or +translation of a Source form, including but not limited to compiled object code, +generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made +available under the License, as indicated by a copyright notice that is included +in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that +is based on (or derived from) the Work and for which the editorial revisions, +annotations, elaborations, or other modifications represent, as a whole, an +original work of authorship. For the purposes of this License, Derivative Works +shall not include works that remain separable from, or merely link (or bind by +name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version +of the Work and any modifications or additions to that Work or Derivative Works +thereof, that is intentionally submitted to Licensor for inclusion in the Work +by the copyright owner or by an individual or Legal Entity authorized to submit +on behalf of the copyright owner. For the purposes of this definition, +"submitted" means any form of electronic, verbal, or written communication sent +to the Licensor or its representatives, including but not limited to +communication on electronic mailing lists, source code control systems, and +issue tracking systems that are managed by, or on behalf of, the Licensor for +the purpose of discussing and improving the Work, but excluding communication +that is conspicuously marked or otherwise designated in writing by the copyright +owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf +of whom a Contribution has been received by Licensor and subsequently +incorporated within the Work. + +2. Grant of Copyright License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the Work and such +Derivative Works in Source or Object form. + +3. Grant of Patent License. + +Subject to the terms and conditions of this License, each Contributor hereby +grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, +irrevocable (except as stated in this section) patent license to make, have +made, use, offer to sell, sell, import, and otherwise transfer the Work, where +such license applies only to those patent claims licensable by such Contributor +that are necessarily infringed by their Contribution(s) alone or by combination +of their Contribution(s) with the Work to which such Contribution(s) was +submitted. If You institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the Work or a +Contribution incorporated within the Work constitutes direct or contributory +patent infringement, then any patent licenses granted to You under this License +for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. + +You may reproduce and distribute copies of the Work or Derivative Works thereof +in any medium, with or without modifications, and in Source or Object form, +provided that You meet the following conditions: + +You must give any other recipients of the Work or Derivative Works a copy of +this License; and +You must cause any modified files to carry prominent notices stating that You +changed the files; and +You must retain, in the Source form of any Derivative Works that You distribute, +all copyright, patent, trademark, and attribution notices from the Source form +of the Work, excluding those notices that do not pertain to any part of the +Derivative Works; and +If the Work includes a "NOTICE" text file as part of its distribution, then any +Derivative Works that You distribute must include a readable copy of the +attribution notices contained within such NOTICE file, excluding those notices +that do not pertain to any part of the Derivative Works, in at least one of the +following places: within a NOTICE text file distributed as part of the +Derivative Works; within the Source form or documentation, if provided along +with the Derivative Works; or, within a display generated by the Derivative +Works, if and wherever such third-party notices normally appear. The contents of +the NOTICE file are for informational purposes only and do not modify the +License. You may add Your own attribution notices within Derivative Works that +You distribute, alongside or as an addendum to the NOTICE text from the Work, +provided that such additional attribution notices cannot be construed as +modifying the License. +You may add Your own copyright statement to Your modifications and may provide +additional or different license terms and conditions for use, reproduction, or +distribution of Your modifications, or for any such Derivative Works as a whole, +provided Your use, reproduction, and distribution of the Work otherwise complies +with the conditions stated in this License. + +5. Submission of Contributions. + +Unless You explicitly state otherwise, any Contribution intentionally submitted +for inclusion in the Work by You to the Licensor shall be under the terms and +conditions of this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify the terms of +any separate license agreement you may have executed with Licensor regarding +such Contributions. + +6. Trademarks. + +This License does not grant permission to use the trade names, trademarks, +service marks, or product names of the Licensor, except as required for +reasonable and customary use in describing the origin of the Work and +reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. + +Unless required by applicable law or agreed to in writing, Licensor provides the +Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, +including, without limitation, any warranties or conditions of TITLE, +NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are +solely responsible for determining the appropriateness of using or +redistributing the Work and assume any risks associated with Your exercise of +permissions under this License. + +8. Limitation of Liability. + +In no event and under no legal theory, whether in tort (including negligence), +contract, or otherwise, unless required by applicable law (such as deliberate +and grossly negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License or +out of the use or inability to use the Work (including but not limited to +damages for loss of goodwill, work stoppage, computer failure or malfunction, or +any and all other commercial damages or losses), even if such Contributor has +been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. + +While redistributing the Work or Derivative Works thereof, You may choose to +offer, and charge a fee for, acceptance of support, warranty, indemnity, or +other liability obligations and/or rights consistent with this License. However, +in accepting such obligations, You may act only on Your own behalf and on Your +sole responsibility, not on behalf of any other Contributor, and only if You +agree to indemnify, defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason of your +accepting any such warranty or additional liability.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Fri Jan 25 14:38:52 2019 +0200 @@ -0,0 +1,422 @@ +# Pelion Device Ready example for MTB_ADV_WISE_1570 (Advantech WISE-1570) + +This application is targetted at Advantech WISE-1570. Specifically MTB_ADV_WISE_1570 which is a reference design using the WISE-1570 module. It is built on mbedOS and uses the "mbed-cloud-client" library to handle the Pelion Platform connection, registration and LWM2M resources. The application simulates a button press every 5 seconds and relays the packet to Arm Pelion IoT platform. + +The current version of the example uses: Mbed OS v5.11.0 and Pelion Cloud Client v2.1.1. + +# Pre-requisites: +1. Hardware: + * Module Testbed v. 2.0.0 (MTB) + * Module Carrier Advantech WISE-1570 v1.0.0. The Module carrier includes 64Mb SPI flash which is used by the Pelion Cloud Client. + * WISE-1570 sensor node with antenna + * A micro USB cable + * A NB-IoT SIM + +2. Software: + * DAPLink for MTB. Download the latest release from https://github.com/ARMmbed/DAPLink/releases. Instructions for flashing and using DAPLink can be found from: https://github.com/ARMmbed/DAPLink/blob/master/docs/USERS-GUIDE.md. The file name is 0250_lpc11u35_mtb_wise1570_0x0000.bin. + * mbed CLI - https://github.com/ARMmbed/mbed-cli + * Pelion account for API keys & developer certificate. + +# Getting started: + +1. Import this example to your local machine. + +2. Move into the example directory and run the command ``` mbed deploy ``` to get all the sources downloaded & added to the current directory. + * Login to your Pelion Cloud account on a browser & follow the steps below: + * Navigate to Device identity > Certificates + * Select the certificate created by your account admin and click on "Download Developer C file" + * Save the file mbed_cloud_dev_credentials.c to the location of the example directory. You have to overwrite the contents of the existing file there. + +3. Select UDP (default) or TCP to be used by Pelion Cloud Client in mbed_app.json. + * For UDP set ```"mcc_transport_mode" : 2``` + * For TCP set ```"mcc_transport_mode" : 0``` + +4. Run the command ``` mbed compile -t GCC_ARM -m MTB_ADV_WISE_1570 ``` to compile the application. The application has been tested to work with all three compilers GCC_ARM, ARM, IAR. + +5. Flash the compiled binary to your device. Open a serial terminal at 115200, 8-N-1 & observe the output. + +6. The device starts the example, connects to network & after a few moments connects & registers to Pelion Cloud. It then prints out a device ID. Make a note of this. + +* You can now check your simulated button counter's value in the Pelion portal as well. +* Navigate to "Device Directory" in the portal and click on your device's device ID (step 5). This will open up a new drawer on the page. +* Scroll down to LWM2M resource "Button_count" and click on it. +* A new window opens and you will be able to see the counter & a graph increment every time the resource value increments. + +7. Congratulations, your device is now connected to Pelion IoT platform. Please proceed to the FW update section now. + +# Demonstrate a remote Firmware update: + +1. Now you need to setup Mbed OS on the device to receive FW updates: + * Login to your Pelion Cloud portal. + * Create an API device key (Access Management -> API Keys -> Create a new API key) + * Ensure you copy the API key generated as this is visible only once. + +2. Install the `CLOUD_SDK_API_KEY` + + `mbed config -G CLOUD_SDK_API_KEY ak_1MDE1...<snip>` + +3. Initialize the certificates for your application: + + ``` mbed dm init -d "<your company name in Pelion DM>" --model-name "<product-model-identifier>" -q --force ``` + + The domain name must have a ".com" as a mandatory requirement and the model name can be an string of your choice. + +### Note the use of --force as this option overrides the defaults provided in the application. This is a mandatory parameter. + +## IMPORTANT: You must initialize the certificates before you flash the device as these certificates need to be embedded within the device in order for it to receive remote updates. + +4. With the certificates initialized, there will now be a ".update-certificates" directory created within the application's root directory. + +5. Now, compile the application: +``` mbed compile -t GCC_ARM -m MTB_ADV_WISE_1570 ``` + +6. Program your device with the .hex file just generated. You can either drag-drop via the GUI of your OS or you can use the corresponding copy command from the terminal for your OS. + +7. Open a serial terminal application such as PuTTY and observe the output. You will notice the device boots up, connects to the network, starts Pelion Cloud Client and registers to the Cloud. + +8. Once the device registers, make a note of the device ID assigned to the device. + +9. Modify the main.cpp in the source directory to add a small printf statement - this is already provided in the code. So, you can un-comment this line in order to demo a FW update. + +10. Use the mbed tool to perform a remote update on the device: + + ``` mbed dm update device -D <device ID> -t GCC_ARM -m MTB_ADV_WISE_1570 ``` + + where device ID is the one obtained from step 8. + +### Note for UDP the update campaign needs to be started in 30 second window after registering. In case you miss this window, just reboot the device, wait for it to register + 30 seconds, and the update should start. This is required because with UDP the only way to start update campaign is to forcibly trigger re-registration to cloud. This is implemented in the main.cpp and only used when UDP is enabled. + +11. You will notice from the serial terminal that the device gets a request to update the FW, then this is authorized, then the download of the new FW starts, finishes and the bootloader verifies the authencity of the new FW, installs it on the device and reboots. + +12. You will now notice the new printf statement appear on the device logs which indicates that the newly built application binary is now installed and running on the device i.e. the device has been remotely updated. + + The success logs should look like the below on a serial terminal, although your device *will* be assigned a different device ID and will have a different IP address. + +``` +mbed sterm -b 115200 -r + +[BOOT] Mbed Bootloader +[BOOT] ARM: 00000000000000000000 +[BOOT] OEM: 00000000000000000000 +[BOOT] Layout: 0 8007698 +[BOOT] Active firmware integrity check: +[BOOT] SHA256: 8A9C5CDF457A2EFD94A36FEC10934C292516249D93F899691000D5E2BD75B2DE +[BOOT] Version: 1547631154 +[BOOT] Slot 0 is empty +[BOOT] Active firmware up-to-date +[BOOT] Application's start address: 0x8008400 +[BOOT] Application's jump address: 0x802E5C5 +[BOOT] Application's stack address: 0x10008000 +[BOOT] Forwarding to application... + +Starting Simple Pelion Device Management Client example +Connecting to the network... +Connected to the network successfully. IP address: 10.41.80.23 +Initialized Pelion Client. Registering... +Simulated button clicked 1 times +Simulated button clicked 2 times +Simulated button clicked 3 times +Simulated button clicked 4 times +Simulated button clicked 5 times +Simulated button clicked 6 times +Simulated button clicked 7 times +Simulated button clicked 8 times +Simulated button clicked 9 times +Simulated button clicked 10 times +Connected to Pelion Device Management. Endpoint Name: 01685603810f00000000000100100300 +Simulated button clicked 11 times +Simulated button clicked 12 times +Simulated button clicked 13 times +Simulated button clicked 14 times +Simulated button clicked 15 times +Simulated button clicked 16 times +Firmware download requested +Authorization granted +Simulated button clicked 17 times +Downloading: [\ ] 0 %Simulated button clicked 18 times +Downloading: [\ ] 0 %Simulated button clicked 19 times +Downloading: [\ ] 1 %Simulated button clicked 20 times +Downloading: [\ ] 1 %Simulated button clicked 21 times +Downloading: [+- ] 2 %Simulated button clicked 22 times +Downloading: [+- ] 2 %Simulated button clicked 23 times +Downloading: [+- ] 3 %Simulated button clicked 24 times +Downloading: [+- ] 3 %Simulated button clicked 25 times +Downloading: [++\ ] 4 %Simulated button clicked 26 times +Downloading: [++\ ] 4 %Simulated button clicked 27 times +Downloading: [++\ ] 5 %Simulated button clicked 28 times +Downloading: [++\ ] 5 %Simulated button clicked 29 times +Downloading: [+++\ ] 6 %Simulated button clicked 30 times +Downloading: [+++\ ] 6 %Simulated button clicked 31 times +Downloading: [+++\ ] 7 %Simulated button clicked 32 times +Downloading: [+++\ ] 7 %Simulated button clicked 33 times +Downloading: [++++/ ] 8 %Simulated button clicked 34 times +Downloading: [++++| ] 8 %Simulated button clicked 35 times +Downloading: [++++| ] 9 %Simulated button clicked 36 times +Downloading: [++++| ] 9 %Simulated button clicked 37 times +Downloading: [+++++| ] 10 %Simulated button clicked 38 times +Downloading: [+++++| ] 10 %Simulated button clicked 39 times +Downloading: [+++++| ] 11 %Simulated button clicked 40 times +Downloading: [++++++/ ] 12 %Simulated button clicked 41 times +Downloading: [++++++/ ] 12 %Simulated button clicked 42 times +Downloading: [++++++/ ] 13 %Simulated button clicked 43 times +Downloading: [++++++/ ] 13 %Simulated button clicked 44 times +Downloading: [+++++++/ ] 14 %Simulated button clicked 45 times +Downloading: [+++++++/ ] 14 %Simulated button clicked 46 times +Downloading: [+++++++/ ] 15 %Simulated button clicked 47 times +Downloading: [+++++++/ ] 15 %Simulated button clicked 48 times +Downloading: [++++++++- ] 16 %Simulated button clicked 49 times +Downloading: [++++++++\ ] 16 %Simulated button clicked 50 times +Downloading: [++++++++\ ] 17 %Simulated button clicked 51 times +Downloading: [++++++++\ ] 17 %Simulated button clicked 52 times +Downloading: [+++++++++- ] 18 %Simulated button clicked 53 times +Downloading: [+++++++++\ ] 18 %Simulated button clicked 54 times +Downloading: [+++++++++\ ] 19 %Simulated button clicked 55 times +Downloading: [+++++++++\ ] 19 %Simulated button clicked 56 times +Downloading: [++++++++++| ] 20 %Simulated button clicked 57 times +Downloading: [++++++++++| ] 20 %Simulated button clicked 58 times +Downloading: [++++++++++| ] 21 %Simulated button clicked 59 times +Downloading: [++++++++++| ] 21 %Simulated button clicked 60 times +Downloading: [+++++++++++| ] 22 %Simulated button clicked 61 times +Downloading: [+++++++++++| ] 22 %Simulated button clicked 62 times +Downloading: [+++++++++++| ] 23 %Simulated button clicked 63 times +Downloading: [++++++++++++/ ] 24 %Simulated button clicked 64 times +Downloading: [++++++++++++/ ] 24 %Simulated button clicked 65 times +Downloading: [++++++++++++/ ] 25 %Simulated button clicked 66 times +Downloading: [++++++++++++/ ] 25 %Simulated button clicked 67 times +Downloading: [+++++++++++++/ ] 26 %Simulated button clicked 68 times +Downloading: [+++++++++++++/ ] 26 %Simulated button clicked 69 times +Downloading: [+++++++++++++/ ] 27 %Simulated button clicked 70 times +Downloading: [+++++++++++++/ ] 27 %Simulated button clicked 71 times +Downloading: [++++++++++++++- ] 28 %Simulated button clicked 72 times +Downloading: [++++++++++++++- ] 28 %Simulated button clicked 73 times +Downloading: [++++++++++++++- ] 29 %Simulated button clicked 74 times +Downloading: [++++++++++++++- ] 29 %Simulated button clicked 75 times +Downloading: [+++++++++++++++- ] 30 %Simulated button clicked 76 times +Downloading: [+++++++++++++++- ] 30 %Simulated button clicked 77 times +Downloading: [+++++++++++++++- ] 31 %Simulated button clicked 78 times +Downloading: [+++++++++++++++- ] 31 %Simulated button clicked 79 times +Downloading: [++++++++++++++++\ ] 32 %Simulated button clicked 80 times +Downloading: [++++++++++++++++\ ] 32 %Simulated button clicked 81 times +Downloading: [++++++++++++++++\ ] 33 %Simulated button clicked 82 times +Downloading: [++++++++++++++++\ ] 33 %Simulated button clicked 83 times +Downloading: [+++++++++++++++++| ] 34 %Simulated button clicked 84 times +Downloading: [+++++++++++++++++\ ] 34 %Simulated button clicked 85 times +Downloading: [+++++++++++++++++| ] 35 %Simulated button clicked 86 times +Downloading: [++++++++++++++++++/ ] 36 %Simulated button clicked 87 times +Downloading: [++++++++++++++++++| ] 36 %Simulated button clicked 88 times +Downloading: [++++++++++++++++++/ ] 37 %Simulated button clicked 89 times +Downloading: [++++++++++++++++++/ ] 37 %Simulated button clicked 90 times +Downloading: [+++++++++++++++++++/ ] 38 %Simulated button clicked 91 times +Downloading: [+++++++++++++++++++/ ] 38 %Simulated button clicked 92 times +Downloading: [+++++++++++++++++++| ] 39 %Simulated button clicked 93 times +Downloading: [+++++++++++++++++++| ] 39 %Simulated button clicked 94 times +Downloading: [++++++++++++++++++++/ ] 40 %Simulated button clicked 95 times +Downloading: [++++++++++++++++++++/ ] 40 %Simulated button clicked 96 times +Downloading: [++++++++++++++++++++/ ] 41 %Simulated button clicked 97 times +Downloading: [++++++++++++++++++++| ] 41 %Simulated button clicked 98 times +Downloading: [++++++++++++++++++++| ] 41 %Simulated button clicked 99 times +Downloading: [+++++++++++++++++++++| ] 42 %Simulated button clicked 100 times +Downloading: [+++++++++++++++++++++| ] 43 %Simulated button clicked 101 times +Downloading: [+++++++++++++++++++++| ] 43 %Simulated button clicked 102 times +Downloading: [++++++++++++++++++++++/ ] 44 %Simulated button clicked 103 times +Downloading: [++++++++++++++++++++++/ ] 44 %Simulated button clicked 104 times +Downloading: [++++++++++++++++++++++/ ] 45 %Simulated button clicked 105 times +Downloading: [++++++++++++++++++++++/ ] 45 %Simulated button clicked 106 times +Downloading: [+++++++++++++++++++++++/ ] 46 %Simulated button clicked 107 times +Downloading: [+++++++++++++++++++++++/ ] 46 %Simulated button clicked 108 times +Downloading: [+++++++++++++++++++++++/ ] 47 %Simulated button clicked 109 times +Downloading: [+++++++++++++++++++++++/ ] 47 %Simulated button clicked 110 times +Downloading: [++++++++++++++++++++++++- ] 48 %Simulated button clicked 111 times +Downloading: [++++++++++++++++++++++++- ] 48 %Simulated button clicked 112 times +Downloading: [++++++++++++++++++++++++- ] 49 %Simulated button clicked 113 times +Downloading: [++++++++++++++++++++++++- ] 49 %Simulated button clicked 114 times +Downloading: [+++++++++++++++++++++++++- ] 50 %Simulated button clicked 115 times +Downloading: [+++++++++++++++++++++++++- ] 50 %Simulated button clicked 116 times +Downloading: [+++++++++++++++++++++++++\ ] 51 %Simulated button clicked 117 times +Downloading: [+++++++++++++++++++++++++\ ] 51 %Simulated button clicked 118 times +Downloading: [++++++++++++++++++++++++++\ ] 52 %Simulated button clicked 119 times +Downloading: [++++++++++++++++++++++++++| ] 52 %Simulated button clicked 120 times +Downloading: [++++++++++++++++++++++++++\ ] 53 %Simulated button clicked 121 times +Downloading: [++++++++++++++++++++++++++| ] 53 %Simulated button clicked 122 times +Downloading: [+++++++++++++++++++++++++++| ] 54 %Simulated button clicked 123 times +Downloading: [+++++++++++++++++++++++++++| ] 55 %Simulated button clicked 124 times +Downloading: [+++++++++++++++++++++++++++| ] 55 %Simulated button clicked 125 times +Downloading: [++++++++++++++++++++++++++++/ ] 56 %Simulated button clicked 126 times +Downloading: [++++++++++++++++++++++++++++/ ] 56 %Simulated button clicked 127 times +Downloading: [++++++++++++++++++++++++++++/ ] 57 %Simulated button clicked 128 times +Downloading: [++++++++++++++++++++++++++++/ ] 57 %Simulated button clicked 129 times +Downloading: [+++++++++++++++++++++++++++++/ ] 58 %Simulated button clicked 130 times +Downloading: [+++++++++++++++++++++++++++++/ ] 58 %Simulated button clicked 131 times +Downloading: [+++++++++++++++++++++++++++++/ ] 59 %Simulated button clicked 132 times +Downloading: [+++++++++++++++++++++++++++++/ ] 59 %Simulated button clicked 133 times +Downloading: [++++++++++++++++++++++++++++++- ] 60 %Simulated button clicked 134 times +Downloading: [++++++++++++++++++++++++++++++- ] 60 %Simulated button clicked 135 times +Downloading: [++++++++++++++++++++++++++++++- ] 61 %Simulated button clicked 136 times +Downloading: [++++++++++++++++++++++++++++++- ] 61 %Simulated button clicked 137 times +Downloading: [+++++++++++++++++++++++++++++++\ ] 62 %Simulated button clicked 138 times +Downloading: [+++++++++++++++++++++++++++++++\ ] 62 %Simulated button clicked 139 times +Downloading: [+++++++++++++++++++++++++++++++| ] 63 %Simulated button clicked 140 times +Downloading: [+++++++++++++++++++++++++++++++\ ] 63 %Simulated button clicked 141 times +Downloading: [++++++++++++++++++++++++++++++++\ ] 64 %Simulated button clicked 142 times +Downloading: [++++++++++++++++++++++++++++++++| ] 64 %Simulated button clicked 143 times +Downloading: [++++++++++++++++++++++++++++++++| ] 65 %Simulated button clicked 144 times +Downloading: [+++++++++++++++++++++++++++++++++/ ] 66 %Simulated button clicked 145 times +Downloading: [+++++++++++++++++++++++++++++++++/ ] 66 %Simulated button clicked 146 times +Downloading: [+++++++++++++++++++++++++++++++++/ ] 67 %Simulated button clicked 147 times +Downloading: [+++++++++++++++++++++++++++++++++/ ] 67 %Simulated button clicked 148 times +Downloading: [++++++++++++++++++++++++++++++++++/ ] 68 %Simulated button clicked 149 times +Downloading: [++++++++++++++++++++++++++++++++++/ ] 68 %Simulated button clicked 150 times +Downloading: [++++++++++++++++++++++++++++++++++/ ] 69 %Simulated button clicked 151 times +Downloading: [++++++++++++++++++++++++++++++++++/ ] 69 %Simulated button clicked 152 times +Downloading: [+++++++++++++++++++++++++++++++++++- ] 70 %Simulated button clicked 153 times +Downloading: [+++++++++++++++++++++++++++++++++++/ ] 70 %Simulated button clicked 154 times +Downloading: [+++++++++++++++++++++++++++++++++++/ ] 71 %Simulated button clicked 155 times +Downloading: [+++++++++++++++++++++++++++++++++++/ ] 71 %Simulated button clicked 156 times +Downloading: [++++++++++++++++++++++++++++++++++++/ ] 72 %Simulated button clicked 157 times +Downloading: [++++++++++++++++++++++++++++++++++++/ ] 72 %Simulated button clicked 158 times +Downloading: [++++++++++++++++++++++++++++++++++++/ ] 73 %Simulated button clicked 159 times +Downloading: [++++++++++++++++++++++++++++++++++++/ ] 73 %Simulated button clicked 160 times +Downloading: [+++++++++++++++++++++++++++++++++++++- ] 74 %Simulated button clicked 161 times +Downloading: [+++++++++++++++++++++++++++++++++++++- ] 74 %Simulated button clicked 162 times +Downloading: [+++++++++++++++++++++++++++++++++++++- ] 75 %Simulated button clicked 163 times +Downloading: [+++++++++++++++++++++++++++++++++++++- ] 75 %Simulated button clicked 164 times +Downloading: [++++++++++++++++++++++++++++++++++++++- ] 76 %Simulated button clicked 165 times +Downloading: [++++++++++++++++++++++++++++++++++++++- ] 76 %Simulated button clicked 166 times +Downloading: [++++++++++++++++++++++++++++++++++++++- ] 77 %Simulated button clicked 167 times +Downloading: [++++++++++++++++++++++++++++++++++++++- ] 77 %Simulated button clicked 168 times +Downloading: [+++++++++++++++++++++++++++++++++++++++\ ] 78 %Simulated button clicked 169 times +Downloading: [+++++++++++++++++++++++++++++++++++++++\ ] 78 %Simulated button clicked 170 times +Downloading: [+++++++++++++++++++++++++++++++++++++++\ ] 79 %Simulated button clicked 171 times +Downloading: [+++++++++++++++++++++++++++++++++++++++\ ] 79 %Simulated button clicked 172 times +Downloading: [++++++++++++++++++++++++++++++++++++++++\ ] 80 %Simulated button clicked 173 times +Downloading: [++++++++++++++++++++++++++++++++++++++++\ ] 80 %Simulated button clicked 174 times +Downloading: [++++++++++++++++++++++++++++++++++++++++- ] 81 %Simulated button clicked 175 times +Downloading: [++++++++++++++++++++++++++++++++++++++++- ] 81 %Simulated button clicked 176 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++\ ] 82 %Simulated button clicked 177 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++\ ] 82 %Simulated button clicked 178 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++\ ] 83 %Simulated button clicked 179 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++\ ] 83 %Simulated button clicked 180 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++\ ] 84 %Simulated button clicked 181 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++\ ] 84 %Simulated button clicked 182 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++| ] 85 %Simulated button clicked 183 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++/ ] 86 %Simulated button clicked 184 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++/ ] 86 %Simulated button clicked 185 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++/ ] 87 %Simulated button clicked 186 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++/ ] 87 %Simulated button clicked 187 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++/ ] 88 %Simulated button clicked 188 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++/ ] 88 %Simulated button clicked 189 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++/ ] 89 %Simulated button clicked 190 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++/ ] 89 %Simulated button clicked 191 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++- ] 90 %Simulated button clicked 192 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++- ] 90 %Simulated button clicked 193 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++- ] 91 %Simulated button clicked 194 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++- ] 91 %Simulated button clicked 195 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++++- ] 92 %Simulated button clicked 196 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++++- ] 92 %Simulated button clicked 197 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++++- ] 93 %Simulated button clicked 198 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++++- ] 93 %Simulated button clicked 199 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++++\ ] 94 %Simulated button clicked 200 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++++\ ] 94 %Simulated button clicked 201 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++++\ ] 95 %Simulated button clicked 202 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++++- ] 95 %Simulated button clicked 203 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++++++- ] 96 %Simulated button clicked 204 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++++++- ] 96 %Simulated button clicked 205 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++++++- ] 97 %Simulated button clicked 206 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++++++- ] 97 %Simulated button clicked 207 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++++++\] 98 %Simulated button clicked 208 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++++++\] 98 %Simulated button clicked 209 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++++++|] 99 %Simulated button clicked 210 times +Downloading: [+++++++++++++++++++++++++++++++++++++++++++++++++|] 99 %Simulated button clicked 211 times +Downloading: [++++++++++++++++++++++++++++++++++++++++++++++++++] 100 % +Download completed +Simulated button clicked 212 times +Firmware install requested +Authorization granted +[BOOT] Mbed Bootloader +[BOOT] ARM: 00000000000000000000 +[BOOT] OEM: 00000000000000000000 +[BOOT] Layout: 0 8007698 +[BOOT] Active firmware integrity check: +[BOOT] SHA256: 8A9C5CDF457A2EFD94A36FEC10934C292516249D93F899691000D5E2BD75B2DE +[BOOT] Version: 1547631154 +[BOOT] Slot 0 firmware integrity check: +[BOOT] SHA256: 8A9C5CDF457A2EFD94A36FEC10934C292516249D93F899691000D5E2BD75B2DE +[BOOT] Version: 1547631342 +[BOOT] Update active firmware using slot 0: +[BOOT] Verify new active firmware: +[BOOT] New active firmware is valid +[BOOT] Application's start address: 0x8008400 +[BOOT] Application's jump address: 0x802E5C5 +[BOOT] Application's stack address: 0x10008000 +[BOOT] Forwarding to application... + +Starting Simple Pelion Device Management Client example +FW updated OTA +Connecting to the network... +Connected to the network successfully. IP address: 10.41.80.5 +Initialized Pelion Client. Registering... +Simulated button clicked 1 times +Simulated button clicked 2 times +Simulated button clicked 3 times +Simulated button clicked 4 times +Simulated button clicked 5 times +Simulated button clicked 6 times +Simulated button clicked 7 times +Simulated button clicked 8 times +Connected to Pelion Device Management. Endpoint Name: 01685614c62f00000000000100100230 +Simulated button clicked 9 times +Simulated button clicked 10 times +Simulated button clicked 11 times +Simulated button clicked 12 times +Simulated button clicked 13 times +Simulated button clicked 14 times +Simulated button clicked 15 times + +``` + +## Also note that the device ID remains the same after the FW update. This indicates that the SOTP regions were not over-written while perfoming the update. + +# Flash and static RAM usage +Default profile, GCC_ARM: +Total Static RAM memory (data + bss): 30752(+30752) bytes +Total Flash memory (text + data): 414014(+414014) bytes + +Default profile, ARM: +Total Static RAM memory (data + bss): 28742(+28742) bytes +Total Flash memory (text + data): 413517(+413517) bytes + +Default profile, IAR: +Total Static RAM memory (data + bss): 28665(+28665) bytes +Total Flash memory (text + data): 356185(+356185) bytes + +Release profile, GCC_ARM: +Total Static RAM memory (data + bss): 30752(+30752) bytes +Total Flash memory (text + data): 396433(+396433) bytes + +Release profile, ARM: +Total Static RAM memory (data + bss): 28742(+28742) bytes +Total Flash memory (text + data): 348980(+348980) bytes + +Release profile, IAR: +Total Static RAM memory (data + bss): 28658(+28658) bytes +Total Flash memory (text + data): 323198(+323198) bytes + +# Dynamic RAM usage (approximate, measurement affects results) + +Debug profile, GCC_ARM: +Unable to measure. Out of memory due to measurement mode overhead. + +Debug profile, ARM: +Unable to measure. Out of memory due to measurement mode overhead. + +Debug profile, IAR: +Unable to measure. Out of memory due to measurement mode overhead. + +Release profile (max used / available), GCC_ARM: +56525 / 67552 + +Release profile (max used / available), ARM: +54613 / 68384 + +Release profile (max used / available), IAR: +52901 / 65536
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bootloader/LICENSE Fri Jan 25 14:38:52 2019 +0200 @@ -0,0 +1,49 @@ +Permissive Binary License + +Version 1.0, September 2015 + +Redistribution. Redistribution and use in binary form, without +modification, are permitted provided that the following conditions are +met: + +1) Redistributions must reproduce the above copyright notice and the + following disclaimer in the documentation and/or other materials + provided with the distribution. + +2) Unless to the extent explicitly permitted by law, no reverse + engineering, decompilation, or disassembly of this software is + permitted. + +3) Redistribution as part of a software development kit must include the + accompanying file named "DEPENDENCIES" and any dependencies listed in + that file. + +4) Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +Limited patent license. The copyright holders (and contributors) grant a +worldwide, non-exclusive, no-charge, royalty-free patent license to +make, have made, use, offer to sell, sell, import, and otherwise +transfer this software, where such license applies only to those patent +claims licensable by the copyright holders (and contributors) that are +necessarily infringed by this software. This patent license shall not +apply to any combinations that include this software. No hardware is +licensed hereunder. + +If you institute patent litigation against any entity (including a +cross-claim or counterclaim in a lawsuit) alleging that the software +itself infringes your patent(s), then your rights granted under this +license shall terminate as of the date such litigation is filed. + +DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND +CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT +NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/bootloader/bootloader_app.json Fri Jan 25 14:38:52 2019 +0200
@@ -0,0 +1,68 @@
+{
+ "macros": [
+ "MBEDTLS_USER_CONFIG_FILE=\"bootloader_mbedtls_user_config.h\"",
+ "SHOW_PROGRESS_BAR=0",
+ "MAX_COPY_RETRIES=1",
+ "MAX_BOOT_RETRIES=3",
+ "ARM_BOOTLOADER_USE_NVSTORE_ROT=1",
+ "ARM_UC_USE_PAL_CRYPTO=0",
+ "ARM_UC_USE_PAL_BLOCKDEVICE=1",
+ "ARM_UC_PAAL_TRACE_ENABLE=0",
+ "ARM_UC_PROFILE_MBED_CLOUD_CLIENT=1",
+ "ARM_UC_FEATURE_CRYPTO_PAL=0",
+ "ARM_UC_FEATURE_CRYPTO_MBEDTLS=1",
+ "MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE",
+ "DEFAULT_MAX_APPLICATION_SIZE=(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - MBED_CONF_APP_APPLICATION_START_ADDRESS)",
+ "DISABLE_ERROR_DESCRIPTION=1",
+ "Mutex=PlatformMutex"
+ ],
+ "config": {
+ "application-start-address": {
+ "help": "Address to the beginning of the active application firmware in flash",
+ "value": null
+ },
+ "application-jump-address": {
+ "help": "Jump address for running the active application firmware",
+ "value": null
+ },
+ "max-application-size": {
+ "help": "Maximum size of the active application",
+ "value": null
+ },
+ "flash-start-address": {
+ "help": "Start address of internal flash. Only used in this config to help the definition of other macros.",
+ "value": null
+ },
+ "flash-size": {
+ "help": "Total size of internal flash. Only used in this config to help the definition of other macros.",
+ "value": null
+ }
+ },
+ "target_overrides": {
+ "*": {
+ "target.features_remove" : ["LWIP"],
+ "target.features_add" : ["COMMON_PAL"],
+ "platform.stdio-baud-rate" : 115200,
+ "platform.stdio-flush-at-exit" : false,
+ "update-client.firmware-header-version": "2"
+ },
+ "MTB_ADV_WISE_1570": {
+ "target.components_add" : ["SPIF"],
+ "target.OUTPUT_EXT" : "bin",
+ "spif-driver.SPI_FREQ" : 20000000,
+ "flash-start-address" : "0x08000000",
+ "flash-size" : "(1024*1024)",
+ "nvstore.area_1_address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 2*(4*1024))",
+ "nvstore.area_1_size" : "(4*1024)",
+ "nvstore.area_2_address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 1*(4*1024))",
+ "nvstore.area_2_size" : "(4*1024)",
+ "update-client.storage-address" : "(1024*1024*2)",
+ "update-client.storage-size" : "(1024*1024*1)",
+ "update-client.storage-locations" : 1,
+ "update-client.storage-page" : 1,
+ "update-client.application-details": "(MBED_CONF_APP_FLASH_START_ADDRESS+32*1024)",
+ "application-start-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS+33*1024)",
+ "max-application-size" : "DEFAULT_MAX_APPLICATION_SIZE - (8*1024)"
+ }
+ }
+}
Binary file bootloader/mbed-bootloader-MTB_ADV_WISE_1570.bin has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Jan 25 14:38:52 2019 +0200
@@ -0,0 +1,192 @@
+// ----------------------------------------------------------------------------
+// Copyright 2016-2018 ARM Ltd.
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------
+#ifndef MBED_TEST_MODE
+
+#include "mbed.h"
+#include "simple-mbed-cloud-client.h"
+#include "LittleFileSystem.h"
+#include "mbed_shared_queues.h"
+
+// An event queue is a very useful structure to debounce information between contexts (e.g. ISR and normal threads)
+// This is great because things such as network operations are illegal in ISR, so updating a resource in a button's fall() function is not allowed
+EventQueue eventQueue;
+
+// Default block device
+BlockDevice *bd = BlockDevice::get_default_instance();
+LittleFileSystem fs("fs");
+StorageHelper sh(bd, &fs);
+
+// Default network interface object
+NetworkInterface *net = NetworkInterface::get_default_instance();
+
+// Declaring pointers for access to Pelion Device Management Client resources outside of main()
+MbedCloudClientResource *button_res;
+MbedCloudClientResource *pattern_res;
+
+// SimpleMbedCloudClient handles registering over LwM2M to Pelion Device Management
+SimpleMbedCloudClient *client;
+
+// shared EventQueue for scheduling client re-registration
+events::EventQueue *_shared_queue = mbed::mbed_event_queue();
+
+// This function gets triggered by the timer. It's easy to replace it by an InterruptIn and fall() mode on a real button
+void fake_button_press() {
+ int v = button_res->get_value_int() + 1;
+
+ button_res->set_value(v);
+
+ printf("Simulated button clicked %d times\n", v);
+}
+
+/**
+ * PUT handler
+ * @param resource The resource that triggered the callback
+ * @param newValue Updated value for the resource
+ */
+void pattern_updated(MbedCloudClientResource *resource, m2m::String newValue) {
+ printf("PUT received, new value: %s\n", newValue.c_str());
+}
+
+/**
+ * POST handler
+ * @param resource The resource that triggered the callback
+ * @param buffer If a body was passed to the POST function, this contains the data.
+ * Note that the buffer is deallocated after leaving this function, so copy it if you need it longer.
+ * @param size Size of the body
+ */
+void blink_callback(MbedCloudClientResource *resource, const uint8_t *buffer, uint16_t size) {
+ printf("POST received. Going to blink LED pattern: %s\n", pattern_res->get_value().c_str());
+
+ static DigitalOut augmentedLed(LED1); // LED that is used for blinking the pattern
+
+ // Parse the pattern string, and toggle the LED in that pattern
+ string s = std::string(pattern_res->get_value().c_str());
+ size_t i = 0;
+ size_t pos = s.find(':');
+ while (pos != string::npos) {
+ wait_ms(atoi(s.substr(i, pos - i).c_str()));
+ augmentedLed = !augmentedLed;
+
+ i = ++pos;
+ pos = s.find(':', pos);
+
+ if (pos == string::npos) {
+ wait_ms(atoi(s.substr(i, s.length()).c_str()));
+ augmentedLed = !augmentedLed;
+ }
+ }
+}
+
+/**
+ * Notification callback handler
+ * @param resource The resource that triggered the callback
+ * @param status The delivery status of the notification
+ */
+void button_callback(MbedCloudClientResource *resource, const NoticationDeliveryStatus status) {
+ printf("Button notification, status %s (%d)\n", MbedCloudClientResource::delivery_status_to_string(status), status);
+}
+
+#if defined(MBED_CLOUD_CLIENT_TRANSPORT_MODE_UDP) || defined(MBED_CLOUD_CLIENT_TRANSPORT_MODE_UDP_QUEUE)
+static bool register_update_called = false;
+/**
+ * shared EventQueue callback handler for client re-registration
+ */
+static void reregister_callback(void)
+{
+ client->register_update();
+}
+#endif
+
+/**
+ * Registration callback handler
+ * @param endpoint Information about the registered endpoint such as the name (so you can find it back in portal)
+ */
+void registered(const ConnectorClientEndpointInfo *endpoint) {
+ printf("Connected to Pelion Device Management. Endpoint Name: %s\n", endpoint->internal_endpoint_name.c_str());
+
+ /* When using UDP, start re-registration 30s after initial registration. Allows update campaign to start. */
+ #if defined(MBED_CLOUD_CLIENT_TRANSPORT_MODE_UDP) || defined(MBED_CLOUD_CLIENT_TRANSPORT_MODE_UDP_QUEUE)
+ if(!register_update_called) {
+ register_update_called = true;
+ _shared_queue->call_in(30000, reregister_callback);
+ }
+ #endif
+}
+
+int main(void) {
+ // Call StorageHelper to initialize FS for us
+ sh.init();
+
+ // Initialize client only after making sure FS is ready
+ client = new SimpleMbedCloudClient(net, bd, &fs);
+
+ printf("Starting Simple Pelion Device Management Client example\n");
+ //Uncomment the following line to demonstrate update
+ //printf("FW updated OTA\n");
+ printf("Connecting to the network...\n");
+
+ // Connect to the internet (DHCP is expected to be on)
+ nsapi_error_t status = net->connect();
+
+ if (status != NSAPI_ERROR_OK) {
+ printf("Connecting to the network failed %d!\n", status);
+ return -1;
+ }
+
+ printf("Connected to the network successfully. IP address: %s\n", net->get_ip_address());
+
+ // SimpleMbedCloudClient handles registering over LwM2M to Pelion Device Management
+ int client_status = client->init();
+ if (client_status != 0) {
+ printf("Pelion Client initialization failed (%d)\n", client_status);
+ return -1;
+ }
+
+ // Creating resources, which can be written or read from the cloud
+ button_res = client->create_resource("3200/0/5501", "button_count");
+ button_res->set_value(0);
+ button_res->methods(M2MMethod::GET);
+ button_res->observable(true);
+ button_res->attach_notification_callback(button_callback);
+
+ pattern_res = client->create_resource("3201/0/5853", "blink_pattern");
+ pattern_res->set_value("500:500:500:500:500:500:500:500");
+ pattern_res->methods(M2MMethod::GET | M2MMethod::PUT);
+ pattern_res->attach_put_callback(pattern_updated);
+
+ MbedCloudClientResource *blink_res = client->create_resource("3201/0/5850", "blink_action");
+ blink_res->methods(M2MMethod::POST);
+ blink_res->attach_post_callback(blink_callback);
+
+ printf("Initialized Pelion Client. Registering...\n");
+
+ // Callback that fires when registering is complete
+ client->on_registered(®istered);
+
+ // Register with Pelion Device Management
+ client->register_and_connect();
+
+ // Placeholder for callback to update local resource when GET comes.
+ // The timer fires on an interrupt context, but debounces it to the eventqueue, so it's safe to do network operations
+ Ticker timer;
+ timer.attach(eventQueue.event(&fake_button_press), 5.0);
+
+ // You can easily run the eventQueue in a separate thread if required
+ eventQueue.dispatch_forever();
+}
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Fri Jan 25 14:38:52 2019 +0200 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#6a0a86538c0b9b2bfcc4583b1e2b7fea8f4e71e9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json Fri Jan 25 14:38:52 2019 +0200
@@ -0,0 +1,108 @@
+{
+ "macros": [
+ "ARM_UC_USE_PAL_BLOCKDEVICE=1",
+ "MBED_CLOUD_CLIENT_UPDATE_STORAGE=ARM_UCP_FLASHIAP_BLOCKDEVICE",
+ "MBED_CLIENT_USER_CONFIG_FILE=\"mbed_cloud_client_user_config.h\"",
+ "MBED_CLOUD_CLIENT_USER_CONFIG_FILE=\"mbed_cloud_client_user_config.h\"",
+ "PAL_USER_DEFINED_CONFIGURATION=\"sotp_fs_config_MbedOS.h\"",
+ "PAL_FS_MOUNT_POINT_PRIMARY=\"/fs\"",
+ "MBEDTLS_USER_CONFIG_FILE=\"mbedTLSConfig_mbedOS.h\""
+ ],
+ "target_overrides": {
+ "*": {
+ "platform.stdio-baud-rate" : 115200,
+ "platform.stdio-convert-newlines" : true,
+ "mbed-trace.enable" : false
+ },
+ "MTB_ADV_WISE_1570": {
+ "events.shared-stacksize" : 1408,
+ "nanostack-hal.event_loop_thread_stack_size" : 5120,
+ "platform.stdio-baud-rate" : 115200,
+ "target.features_add" : ["BOOTLOADER"],
+ "mcc_transport_mode" : 0,
+ "spif-driver.SPI_FREQ" : 20000000,
+ "target.components_add" : ["SPIF"],
+ "platform.default-serial-baud-rate" : 9600,
+ "target.network-default-interface-type" : "CELLULAR",
+ "cellular.debug-at" : false,
+ "cellular.use-apn-lookup" : false,
+ "mbed-client.sn-coap-duplication-max-msgs-count": 1,
+ "mbed-client.reconnection-count" : 6,
+ "mbed-client.reconnection-interval" : 20,
+ "nsapi.dns-response-wait-time" : 30000,
+ "client_app.pal_dtls_peer_min_timeout" : "20000",
+ "flash-start-address" : "0x08000000",
+ "flash-size" : "(1024*1024)",
+ "sotp-section-1-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 2*(4*1024))",
+ "sotp-section-1-size" : "(4*1024)",
+ "sotp-section-2-address" : "(MBED_CONF_APP_FLASH_START_ADDRESS + MBED_CONF_APP_FLASH_SIZE - 1*(4*1024))",
+ "sotp-section-2-size" : "(4*1024)",
+ "sotp-num-sections" : 2,
+ "target.bootloader_img" : "bootloader/mbed-bootloader-MTB_ADV_WISE_1570.bin",
+ "target.header_offset" : "0x8000",
+ "target.app_offset" : "0x8400",
+ "target.OUTPUT_EXT" : "hex",
+ "update-client.application-details" : "(MBED_CONF_APP_FLASH_START_ADDRESS + 32*1024)",
+ "update-client.storage-address" : "(1024*1024*2)",
+ "update-client.storage-size" : "(1024*1024*1)",
+ "update-client.storage-locations" : "1",
+ "pal-udp-mtu-size" : 1358
+ }
+ },
+ "config": {
+ "format-storage-layer-on-error": {
+ "help": "Whether to format the storage layer when it cannot be read - always disable for production devices!",
+ "value": 1
+ },
+ "developer-mode": {
+ "help": "Enable Developer mode to skip Factory enrollment",
+ "value": 1
+ },
+ "main-stack-size": {
+ "value": 5120
+ },
+ "flash-start-address": {
+ "help": "Start address of internal flash. Only used in this config to help the definition of other macros.",
+ "value": null
+ },
+ "flash-size": {
+ "help": "Total size of internal flash. Only used in this config to help the definition of other macros.",
+ "value": null
+ },
+ "sotp-section-1-address": {
+ "help": "Flash sector address for SOTP sector 1",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_1_ADDRESS",
+ "value": null
+ },
+ "sotp-section-1-size": {
+ "help": "Flash sector size for SOTP sector 1",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_1_SIZE",
+ "value": null
+ },
+ "sotp-section-2-address": {
+ "help": "Flash sector address for SOTP sector 2",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_2_ADDRESS",
+ "value": null
+ },
+ "sotp-section-2-size": {
+ "help": "Flash sector size for SOTP sector 2",
+ "macro_name": "PAL_INTERNAL_FLASH_SECTION_2_SIZE",
+ "value": null
+ },
+ "sotp-num-sections": {
+ "help": "Number of SOTP sections",
+ "macro_name": "PAL_INT_FLASH_NUM_SECTIONS",
+ "value": null
+ },
+ "pal-udp-mtu-size": {
+ "help": "Enforced usage of MTU limits",
+ "macro_name": "PAL_UDP_MTU_SIZE",
+ "value": null
+ },
+ "mcc_transport_mode": {
+ "help": "0 = TCP, 2 = UDP, 3 = UDP_QUEUE_MODE",
+ "macro_name": "MBED_CLOUD_CLIENT_TRANSPORT_MODE",
+ "value": null
+ }
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_cloud_client_user_config.h Fri Jan 25 14:38:52 2019 +0200 @@ -0,0 +1,66 @@ +// ---------------------------------------------------------------------------- +// Copyright 2016-2017 ARM Ltd. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------- + +// This file is a template and it's intented to be copied to the application +// Enable this configuration + +#ifndef MBED_CLOUD_CLIENT_USER_CONFIG_H +#define MBED_CLOUD_CLIENT_USER_CONFIG_H + +#ifdef MBED_CONF_APP_ENDPOINT_TYPE +#define MBED_CLOUD_CLIENT_ENDPOINT_TYPE MBED_CONF_APP_ENDPOINT_TYPE +#else +#define MBED_CLOUD_CLIENT_ENDPOINT_TYPE "default" +#endif + +// Transport mode selection +#if MBED_CLOUD_CLIENT_TRANSPORT_MODE == 0 +//Default, i.e. null +#define MBED_CLOUD_CLIENT_TRANSPORT_MODE_TCP +#elif MBED_CLOUD_CLIENT_TRANSPORT_MODE == 1 +#define MBED_CLOUD_CLIENT_TRANSPORT_MODE_TCP_QUEUE +#elif MBED_CLOUD_CLIENT_TRANSPORT_MODE == 2 +#define MBED_CLOUD_CLIENT_TRANSPORT_MODE_UDP +#elif MBED_CLOUD_CLIENT_TRANSPORT_MODE == 3 +#define MBED_CLOUD_CLIENT_TRANSPORT_MODE_UDP_QUEUE +#endif + +#define MBED_CLOUD_CLIENT_LIFETIME 3600 + +#define SN_COAP_MAX_BLOCKWISE_PAYLOAD_SIZE 1024 + +// set flag to enable update support in mbed Cloud client +#define MBED_CLOUD_CLIENT_SUPPORT_UPDATE + +// set download buffer size in bytes (min. 1024 bytes) + +// Use larger buffers in Linux // +#ifdef __linux__ +#define MBED_CLOUD_CLIENT_UPDATE_BUFFER (2 * 1024 * 1024) +#else +#define MBED_CLOUD_CLIENT_UPDATE_BUFFER 2048 +#endif + +// Developer flags for Update feature +#if MBED_CONF_APP_DEVELOPER_MODE == 1 + #define MBED_CLOUD_DEV_UPDATE_CERT + #define MBED_CLOUD_DEV_UPDATE_ID +#endif // MBED_CONF_APP_DEVELOPER_MODE + +#endif // MBED_CLOUD_CLIENT_USER_CONFIG_H +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_cloud_dev_credentials.c Fri Jan 25 14:38:52 2019 +0200
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2017 ARM Limited. All rights reserved.
+ * SPDX-License-Identifier: Apache-2.0
+ * Licensed under the Apache License, Version 2.0 (the License); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __MBED_CLOUD_DEV_CREDENTIALS_H__
+#define __MBED_CLOUD_DEV_CREDENTIALS_H__
+
+#if MBED_CONF_APP_DEVELOPER_MODE == 1
+#error "Replace mbed_cloud_dev_credentials.c with your own developer cert."
+#endif
+
+#include <inttypes.h>
+
+const char MBED_CLOUD_DEV_BOOTSTRAP_ENDPOINT_NAME[] = "";
+const char MBED_CLOUD_DEV_ACCOUNT_ID[] = "";
+const char MBED_CLOUD_DEV_BOOTSTRAP_SERVER_URI[] = "";
+
+const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE[] =
+{ 0x0 };
+
+const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE[] =
+{ 0x0 };
+
+const uint8_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY[] =
+{ 0x0 };
+
+const char MBED_CLOUD_DEV_MANUFACTURER[] = "dev_manufacturer";
+
+const char MBED_CLOUD_DEV_MODEL_NUMBER[] = "dev_model_num";
+
+const char MBED_CLOUD_DEV_SERIAL_NUMBER[] = "0";
+
+const char MBED_CLOUD_DEV_DEVICE_TYPE[] = "dev_device_type";
+
+const char MBED_CLOUD_DEV_HARDWARE_VERSION[] = "dev_hardware_version";
+
+const uint32_t MBED_CLOUD_DEV_MEMORY_TOTAL_KB = 0;
+const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_CERTIFICATE);
+const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_SERVER_ROOT_CA_CERTIFICATE);
+const uint32_t MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY_SIZE = sizeof(MBED_CLOUD_DEV_BOOTSTRAP_DEVICE_PRIVATE_KEY);
+
+#endif //__MBED_CLOUD_DEV_CREDENTIALS_H__
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed_settings.py Fri Jan 25 14:38:52 2019 +0200 @@ -0,0 +1,45 @@ +""" +mbed SDK +Copyright (c) 2016 ARM Limited + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +from os.path import join, abspath, dirname + +#ROOT = abspath(join(dirname(__file__), ".")) + +############################################################################## +# Build System Settings +############################################################################## +#BUILD_DIR = abspath(join(ROOT, "build")) + +# ARM +#ARM_PATH = "C:/Program Files/ARM" + +# GCC ARM +#GCC_ARM_PATH = "" + +# IAR +#IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" + +# Goanna static analyser. Please overload it in private_settings.py +#GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" + +#BUILD_OPTIONS = [] + +# mbed.org username +#MBED_ORG_USER = "" + +# Print compiler warnings and errors as link format +#PRINT_COMPILER_OUTPUT_AS_LINK = False
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/simple-mbed-cloud-client.lib Fri Jan 25 14:38:52 2019 +0200 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/simple-mbed-cloud-client/#5c878b548b4d8870c5a172057002daf05504990d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/update_default_resources.c Fri Jan 25 14:38:52 2019 +0200
@@ -0,0 +1,41 @@
+// ----------------------------------------------------------------------------
+// Copyright 2016-2017 ARM Ltd.
+//
+// SPDX-License-Identifier: Apache-2.0
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ----------------------------------------------------------------------------
+
+#ifdef MBED_CLOUD_CLIENT_USER_CONFIG_FILE
+#include MBED_CLOUD_CLIENT_USER_CONFIG_FILE
+#endif
+
+#include <stdint.h>
+
+#ifdef MBED_CLOUD_DEV_UPDATE_ID
+const uint8_t arm_uc_vendor_id[16] = { "dev_manufacturer" };
+const uint16_t arm_uc_vendor_id_size = sizeof(arm_uc_vendor_id);
+
+const uint8_t arm_uc_class_id[16] = { "dev_model_number" };
+const uint16_t arm_uc_class_id_size = sizeof(arm_uc_class_id);
+#endif
+
+#ifdef MBED_CLOUD_DEV_UPDATE_CERT
+const uint8_t arm_uc_default_fingerprint[32] = { 0 };
+const uint16_t arm_uc_default_fingerprint_size =
+ sizeof(arm_uc_default_fingerprint);
+
+const uint8_t arm_uc_default_certificate[1] = { 0 };
+const uint16_t arm_uc_default_certificate_size =
+ sizeof(arm_uc_default_certificate);
+#endif