Indoor positioning. Peripheral unit.
Dependencies: aconno_SEGGER_RTT
Revision 0:ad937152493a, committed 2018-03-06
- Comitter:
- jurica238814
- Date:
- Tue Mar 06 09:53:36 2018 +0000
- Commit message:
- Publish commit.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,57 @@ +# Getting started with Blinky on mbed OS + +This guide reviews 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). + +## Import 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`, and specify 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 see 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. + +The LED on your platform turns on and off. + +## Troubleshooting + +If you have problems, you can review the [documentation](https://os.mbed.com/docs/latest/tutorials/debugging.html) for suggestions on what could be wrong and how to fix it.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SEGGER_RTT.lib Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/jurica238814/code/aconno_SEGGER_RTT/#e61e7fc7cfe1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aconno_ble/aconno_ble.cpp Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,29 @@ +/* + * Made by Jurica Resetar @ aconno + * More info @ aconno.de + * + */ + +#include "aconno_ble.h" + +/** +* Callback triggered when the ble initialization process has finished +*/ +void bleInitComplete(BLE::InitializationCompleteCallbackContext *params){ + BLE& ble = params->ble; + ble_error_t error = params->error; + + if (error != BLE_ERROR_NONE) { + return; + } + + /* Ensure that it is the default instance of BLE */ + if(ble.getInstanceID() != BLE::DEFAULT_INSTANCE) { + return; + } + + /* setup advertising */ + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME, (uint8_t *)DEVICE_NAME, sizeof(DEVICE_NAME)); + ble.gap().accumulateAdvertisingPayload(GapAdvertisingData::MANUFACTURER_SPECIFIC_DATA, (uint8_t *)MSD, MSD_SIZE_b); + ble.gap().setAdvertisingInterval(ADV_INTERVAL_MS); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/aconno_ble/aconno_ble.h Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,27 @@ +/* +* Made by Jurica Resetar @ aconno +* More info @ aconno.de +* jurica_resetar@yahoo.com +*/ + +#ifndef ACONNO_BLE_H +#define ACONNO_BLE_H + +#include "mbed.h" +#include "ble/BLE.h" +#include "GapAdvertisingData.h" + +#define MSD_SIZE_b (10) +#define ADV_INTERVAL_MS (100) +#define ADVERTISING_DURATION_S (1) +#define BLE_SLEEP_DURATION_S (1) + + +/* Global variables and constants */ +const char DEVICE_NAME[] = "aconno beacon"; +const char MSD[MSD_SIZE_b] = {0x59, 0x00, 0x9C, 0x23, 0x9D, 0x82, 0x1B, 0xD4, 0x11, 0xE8}; + +/* Function declarations */ +void bleInitComplete(BLE::InitializationCompleteCallbackContext *params); + +#endif //ACONNO_BLE_H \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#91e6db1ea251ffcc973001ed90477f42fdca5751
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/main.cpp Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,28 @@ +/* + * + * + */ + +#include "main.h" + +int main() +{ + printf("Main program started.\r\n"); + + BLE &ble = BLE::Instance(); + ble.init(bleInitComplete); + printf("BLE initialised.\r\n"); + + #if DEBUG_LED + advLed = 1; + #endif + + bleT.start(callback(bleF, &ble)); + + while(true) + { + //wait_ms(1000); + // Do nothing + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/source/main.h Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,31 @@ +/* + * + * + */ + +#ifndef MAIN_H +#define MAIN_H + +#include "mbed.h" +#include "aconno_ble.h" +#include "tasks.h" +#include "ble/BLE.h" +#include "GapAdvertisingData.h" + +#define DEBUG_LED (1) +#define PRINT_ON_RTT (1) + +#if PRINT_ON_RTT + #include "SEGGER_RTT.h" + #define printf(...) SEGGER_RTT_printf(0, __VA_ARGS__) +#else + #define printf(...) +#endif + +Thread bleT; + +#if DEBUG_LED + DigitalOut advLed(p22); +#endif + +#endif // MAIN_H \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tasks/tasks.cpp Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,31 @@ +/* + * + * + */ + +#include "tasks.h" + +#if DEBUG_LED + extern DigitalOut advLed; +#endif + +void bleF(BLE *ble) +{ + while(true) + { + ble->gap().startAdvertising(); + //printf("Advertisement started.\r\n"); + #if DEBUG_LED + advLed = 0; + #endif + wait(ADVERTISING_DURATION_S); + wait_ms(1000); + ble->gap().stopAdvertising(); + //printf("Advertisement stopped.\r\n"); + #if DEBUG_LED + advLed = 1; + #endif + wait(BLE_SLEEP_DURATION_S); + wait_ms(1000); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tasks/tasks.h Tue Mar 06 09:53:36 2018 +0000 @@ -0,0 +1,18 @@ +/* + * + * + */ + +#ifndef TASKS_H +#define TASKS_H + +#include "mbed.h" +#include "aconno_ble.h" +#include "ble/BLE.h" +#include "GapAdvertisingData.h" + +#define DEBUG_LED (1) + +void bleF(BLE *ble); + +#endif // TASKS_H \ No newline at end of file