Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:5c135386bc5a, committed 2016-11-22
- Comitter:
- azazeal88
- Date:
- Tue Nov 22 09:46:18 2016 +0000
- Child:
- 1:64cc3006c472
- Commit message:
- Initial Commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Tue Nov 22 09:46:18 2016 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Tue Nov 22 09:46:18 2016 +0000 @@ -0,0 +1,89 @@ +# Getting started with Blinky on mbed OS + +This is a very simple guide, reviewing the steps required to get Blinky working on an mbed OS platform. + +Please install [mbed CLI](https://github.com/ARMmbed/mbed-cli#installing-mbed-cli). + +## Get the example application! + +From the command line, import the example: + +``` +mbed import mbed-os-example-blinky +cd mbed-os-example-blinky +``` + +### Now compile + +Invoke `mbed compile` specifying the name of your platform and your favorite toolchain (`GCC_ARM`, `ARM`, `IAR`). For example, for the ARM Compiler 5: + +``` +mbed compile -m K64F -t ARM +``` + +Your PC may take a few minutes to compile your code. At the end you should get the following result: + +``` +[snip] ++----------------------------+-------+-------+------+ +| Module | .text | .data | .bss | ++----------------------------+-------+-------+------+ +| Misc | 13939 | 24 | 1372 | +| core/hal | 16993 | 96 | 296 | +| core/rtos | 7384 | 92 | 4204 | +| features/FEATURE_IPV4 | 80 | 0 | 176 | +| frameworks/greentea-client | 1830 | 60 | 44 | +| frameworks/utest | 2392 | 512 | 292 | +| Subtotals | 42618 | 784 | 6384 | ++----------------------------+-------+-------+------+ +Allocated Heap: unknown +Allocated Stack: unknown +Total Static RAM memory (data + bss): 7168 bytes +Total RAM memory (data + bss + heap + stack): 7168 bytes +Total Flash memory (text + data + misc): 43402 bytes +Image: .\.build\K64F\ARM\mbed-os-example-blinky.bin +``` + +### Program your board + +1. Connect your mbed device to the computer over USB. +1. Copy the binary file to the mbed device . +1. Press the reset button to start the program. + +You should see the LED of your platform turning on and off. + +Congratulations if you managed to complete this test! + +## Export the project to Keil MDK and debug your application + +From the command line, run the following command: + +``` +mbed export -m K64F -i uvision +``` + +To debug the application: + +1. Start uVision. +1. Import the uVision project generated earlier. +1. Compile your application and generate an `.axf` file. +1. Make sure uVision is configured to debug over CMSIS-DAP (From the Project menu > Options for Target '...' > Debug tab > Use CMSIS-DAP Debugger). +1. Set breakpoints and start a debug session. + + + +## Troubleshooting + +1. Make sure `mbed-cli` is working correctly and its version is greater than `0.8.9` + + ``` + mbed --version + ``` + + If not, you can update it easily: + + ``` + pip install mbed-cli --upgrade + ``` + +2. If using Keil MDK, make sure you have a license installed. [MDK-Lite](http://www.keil.com/arm/mdk.asp) has a 32KB restriction on code size.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RN2483.lib Tue Nov 22 09:46:18 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/azazeal88/code/RN2483/#7b3abd00c921
Binary file img/uvision.png has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Nov 22 09:46:18 2016 +0000
@@ -0,0 +1,301 @@
+#include "mbed.h"
+#include "RN2483.h"
+
+Serial pc(USBTX, USBRX);
+
+// Lora Declarations - using unpopulated header on K64F
+RN2483 lorabee(D1, D0); // tx, rx
+DigitalInOut loraResetPin(PTB9);
+
+// Provisioned on network server.
+const uint8_t devEUI[8] =
+{0x09, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};
+
+const uint8_t appEUI[8] =
+{0x09, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01};
+
+const uint8_t appKey[16] =
+{0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23};
+
+const uint8_t devAddr[4] =
+{0x094, 0x19, 0x27, 0xf4};
+
+const uint8_t appSKey[16] =
+{0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23};
+
+const uint8_t nwkSKey[16] =
+{0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23};
+
+uint8_t testPayload[] =
+{
+ 0x30, 0x31, 0xFF, 0xDE, 0xAD
+};
+
+// Foward Declarations
+void printMenu();
+void hardwareResetLoRa();
+int timedRead(Serial &, unsigned long);
+size_t readBytesUntil(Serial &, char, char *, size_t);
+void configJoinNetworkOTTA();
+void configJoinNetworkABP();
+void joinOTTA();
+void joinABP();
+void sleepWakeupTest();
+void readVDDTest();
+void setBatteryTest();
+void setLinkCheckIntervalTest();
+void forceEnableTest();
+void sendACK();
+void send();
+void printHWEUI();
+
+int main() {
+ pc.baud(38400);
+ hardwareResetLoRa();
+ printMenu();
+ while(true){
+ char buffer[5];
+ int bytesRead = readBytesUntil(pc, '\n', buffer, 5);
+ if(bytesRead>0){
+ switch (strtol(buffer,NULL,10)){
+ case 1:
+ configJoinNetworkOTTA();
+ break;
+ case 2:
+ configJoinNetworkABP();
+ break;
+ case 3:
+ joinOTTA();
+ break;
+ case 4:
+ joinABP();
+ break;
+ case 5:
+ sleepWakeupTest();
+ break;
+ case 6:
+ readVDDTest();
+ break;
+ case 7:
+ setBatteryTest();
+ break;
+ case 8:
+ setLinkCheckIntervalTest();
+ break;
+ case 9:
+ forceEnableTest();
+ break;
+ case 10:
+ sendACK();
+ break;
+ case 11:
+ send();
+ break;
+ case 12:
+ printHWEUI();
+ break;
+ default:
+ printf("Invalid Choice");
+ break;
+ }
+ Thread::wait(3000);
+ printMenu();
+ }
+ }
+}
+
+void printMenu(){
+ printf("------------------------\r\n");
+ printf("Config Join OTTA : 1\r\n");
+ printf("Config Join ABP : 2\r\n");
+ printf("Join OTTA : 3\r\n");
+ printf("Join ABP : 4\r\n");
+ printf("Sleep Wakeup : 5\r\n");
+ printf("Read VDD : 6\r\n");
+ printf("Set Battery : 7\r\n");
+ printf("Link Check Test : 8\r\n");
+ printf("Force Enable : 9\r\n");
+ printf("Send Ack MSG : 10\r\n");
+ printf("Send NoAck MSG : 11\r\n");
+ printf("Print HWEUI : 12\r\n");
+ printf("------------------------\r\n");
+}
+
+void hardwareResetLoRa() {
+ loraResetPin.input();
+ Thread::wait(500);
+ loraResetPin.output() ;
+ loraResetPin = 1;
+ Thread::wait(500);
+}
+
+void configJoinNetworkOTTA(){
+ printf("Network (OTA) Join %s\r\n", lorabee.initOTA(devEUI,appEUI,appKey,true) ? "Success": "Failed");
+}
+
+void configJoinNetworkABP(){
+ printf("Network (ABP) Join %s\r\n", lorabee.initABP(devAddr, appSKey, nwkSKey, true) ? "Success": "Failed");
+}
+
+void joinOTTA(){
+ printf("Network (OTTA) Join %s\r\n", lorabee.joinOTTA() ? "Success": "Failed");
+}
+
+void joinABP(){
+ printf("Network (ABP) Join %s\r\n", lorabee.joinABP() ? "Success": "Failed");
+}
+
+void sleepWakeupTest(){
+ printf("RN2483 Sleeping for 10 seconds.\r\n");
+ lorabee.sleep(10000);
+ Thread::wait(20000);
+ printf("RN2483 Sleeping for 60 seconds.\r\n");
+ lorabee.sleep(60000);
+ Thread::wait(20000);
+ lorabee.wakeUp();
+ printf("RN2483 was told to wake up.\r\n");
+}
+
+void readVDDTest(){
+ long vdd;
+ if (lorabee.getVDD(&vdd)){
+ printf("RN2483 voltage in mV %ld.\r\n", vdd);
+ } else {
+ printf("Error reading VDD");
+ }
+
+}
+
+void setBatteryTest(){
+ printf("Battery Setting to 50percent %s\r\n", lorabee.setBattery(125) ? "Success": "Failed");
+ Thread::wait(2000);
+ printf("Battery Setting to external power %s\r\n", lorabee.setBattery(0) ? "Success": "Failed");
+ Thread::wait(2000);
+ printf("Battery Setting to unable to read power %s\r\n", lorabee.setBattery(255) ? "Success": "Failed");
+}
+
+void setLinkCheckIntervalTest(){
+ printf("Set Link Check 120 seconds %s\r\n", lorabee.setLinkCheckInterval(120) ? "Success": "Failed");
+ Thread::wait(2000);
+ printf("Set Link Check Disable seconds %s\r\n", lorabee.setLinkCheckInterval(0) ? "Success": "Failed");
+}
+
+void forceEnableTest(){
+ printf("Remove silence %s\r\n", lorabee.forceEnable() ? "Success": "Failed");
+}
+
+void printHWEUI(){
+ uint8_t buffer[10];
+ uint8_t bufferSize = lorabee.getHWEUI(buffer,10);
+ printf("Hardware EUI: ");
+ if(bufferSize > 0){
+ for(int i = 0; i < bufferSize; i++){
+ printf("%x",buffer[i]);
+ }
+ }
+ printf("\r\n");
+}
+
+void sendACK(){
+ switch (lorabee.sendReqAck(1, testPayload, 5, 3))
+ {
+ case NoError:
+ printf("Successful transmission.\r\n");
+ break;
+ case NoResponse:
+ printf("There was no response from the device.\r\n");
+ break;
+ case Silent:
+ printf("The device was silenced\r\n");
+ break;
+ case Timedout:
+ printf("Connection timed-out. Check your serial connection to the device!\r\n");
+ break;
+ case PayloadSizeError:
+ printf("The size of the payload is greater than allowed. Transmission failed!\r\n");
+ break;
+ case InternalError:
+ printf("Serious Error\r\n.");
+ break;
+ case Busy:
+ printf("The device is busy.\r\n");
+ break;
+ case NetworkFatalError:
+ printf("There is a non-recoverable error with the network connection. You should re-connect.\r\n");
+ break;
+ case NotConnected:
+ printf("The device is not connected to the network. Please connect to the network before attempting to send data.\r\n");
+ break;
+ case NoAcknowledgment:
+ printf("There was no acknowledgment sent back!\r\n");
+ break;
+ default:
+ break;
+ }
+}
+
+void send(){
+ switch (lorabee.send(1, testPayload, 5))
+ {
+ case NoError:
+ printf("Successful transmission.\r\n");
+ break;
+ case NoResponse:
+ printf("There was no response from the device.\r\n");
+ break;
+ case Silent:
+ printf("The device was silenced\r\n");
+ break;
+ case Timedout:
+ printf("Connection timed-out. Check your serial connection to the device!\r\n");
+ break;
+ case PayloadSizeError:
+ printf("The size of the payload is greater than allowed. Transmission failed!\r\n");
+ break;
+ case InternalError:
+ printf("Serious Error\r\n.");
+ break;
+ case Busy:
+ printf("The device is busy.\r\n");
+ break;
+ case NetworkFatalError:
+ printf("There is a non-recoverable error with the network connection. You should re-connect.\r\n");
+ break;
+ case NotConnected:
+ printf("The device is not connected to the network. Please connect to the network before attempting to send data.\r\n");
+ break;
+ default:
+ break;
+ }
+}
+
+int timedRead(Serial &serialInterface, unsigned long _timeout){
+ int c;
+ Timer t;
+ t.start();
+ unsigned long _startMillis = t.read_ms(); // get milliseconds
+ while (! serialInterface.readable() && t.read_ms() - _startMillis <_timeout) {
+ Thread::yield();
+ }
+ t.stop();
+ if(serialInterface.readable()){
+ c = serialInterface.getc();
+ if (c >= 0){
+ return c;
+ }
+ }
+ return -1; // -1 indicates timeout
+}
+
+size_t readBytesUntil(Serial &serialInterface, char terminator, char *buffer, size_t length)
+{
+ if (length < 1) return 0;
+ size_t index = 0;
+ while (index < length) {
+ int c = timedRead(serialInterface, 1000);
+ if (c < 0 || c == terminator) break;
+ *buffer++ = (char)c;
+ index++;
+ }
+ return index; // return number of characters, not including null terminator
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Nov 22 09:46:18 2016 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#a1c0840b3d69060e5eb708edb18358e424a40f51