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:477ffc11d92b, committed 2018-08-30
- Comitter:
- Jun_adi
- Date:
- Thu Aug 30 03:35:10 2018 +0000
- Commit message:
- ADT7410 temp sensing for BLEnano V2
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Thu Aug 30 03:35:10 2018 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ADT7410.lib Thu Aug 30 03:35:10 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/tkreyche/code/ADT7410/#e1aee50340ec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/README.md Thu Aug 30 03:35:10 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/main.cpp Thu Aug 30 03:35:10 2018 +0000
@@ -0,0 +1,169 @@
+/*
+
+Copyright (c) 2012-2014 RedBearLab
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+and associated documentation files (the "Software"), to deal in the Software without restriction,
+including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
+and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
+INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
+PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+*/
+
+/*
+ * The application works with the BlueJelly.js
+ *
+ * http://jellyware.jp/
+ *
+ */
+
+//======================================================================
+//Grobal
+//======================================================================
+//------------------------------------------------------------
+//Include Header Files
+//------------------------------------------------------------
+#include "mbed.h"
+#include "ble/BLE.h"
+#include "ADT7410.h"
+
+//------------------------------------------------------------
+//Definition
+//------------------------------------------------------------
+#define TXRX_BUF_LEN 20 //max 20[byte]
+#define DEVICE_LOCAL_NAME "ADT7410 Temperature" //Change Device name
+#define ADVERTISING_INTERVAL 160 //160 * 0.625[ms] = 100[ms]
+#define DIGITAL_OUT_PIN P0_29
+
+//------------------------------------------------------------
+//Object generation
+//------------------------------------------------------------
+BLE blenano;
+DigitalOut LED_SET(DIGITAL_OUT_PIN);
+
+//I2C Pin setting P0_4=SDA, P0_5=SCL
+ADT7410 temp(P0_5, P0_4, 0x90, 10000);
+
+
+//------------------------------------------------------------
+//Service & Characteristic Setting
+//------------------------------------------------------------
+//Service UUID
+static const uint8_t base_uuid[] = { 0x71, 0x3D, 0x00, 0x00, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E } ;
+
+//Characteristic UUID
+static const uint8_t tx_uuid[] = { 0x71, 0x3D, 0x00, 0x03, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E } ;
+static const uint8_t rx_uuid[] = { 0x71, 0x3D, 0x00, 0x02, 0x50, 0x3E, 0x4C, 0x75, 0xBA, 0x94, 0x31, 0x48, 0xF1, 0x8D, 0x94, 0x1E } ;
+
+//Characteristic Value
+uint8_t txPayload[TXRX_BUF_LEN] = {0,};
+uint8_t rxPayload[TXRX_BUF_LEN] = {0,};
+
+//Characteristic Property Setting etc
+GattCharacteristic txCharacteristic (tx_uuid, txPayload, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_WRITE | GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
+GattCharacteristic rxCharacteristic (rx_uuid, rxPayload, 1, TXRX_BUF_LEN, GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_NOTIFY| GattCharacteristic::BLE_GATT_CHAR_PROPERTIES_READ);
+GattCharacteristic *myChars[] = {&txCharacteristic, &rxCharacteristic};
+
+//Service Setting
+GattService myService(base_uuid, myChars, sizeof(myChars) / sizeof(GattCharacteristic *));
+
+
+//======================================================================
+//onDisconnection
+//======================================================================
+void disconnectionCallback(const Gap::DisconnectionCallbackParams_t *params)
+{
+ blenano.startAdvertising();
+}
+
+
+//======================================================================
+//convert reverse UUID
+//======================================================================
+void reverseUUID(const uint8_t* src, uint8_t* dst)
+{
+ int i;
+
+ for(i=0;i<16;i++)
+ dst[i] = src[15 - i];
+}
+
+
+//======================================================================
+//main
+//======================================================================
+int main(void)
+{
+ uint8_t base_uuid_rev[16];
+
+ //BLE init
+ blenano.init();
+
+ //EventListener
+ blenano.onDisconnection(disconnectionCallback);
+ //blenano.onDataWritten(WrittenHandler);
+
+ //------------------------------------------------------------
+ //setup advertising
+ //------------------------------------------------------------
+ //Classic BT not support
+ blenano.accumulateAdvertisingPayload(GapAdvertisingData::BREDR_NOT_SUPPORTED);
+
+ //Connectable to Central
+ blenano.setAdvertisingType(GapAdvertisingParams::ADV_CONNECTABLE_UNDIRECTED);
+
+ //Local Name
+ blenano.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LOCAL_NAME,
+ (const uint8_t *)DEVICE_LOCAL_NAME, sizeof(DEVICE_LOCAL_NAME) - 1);
+
+ //GAP AdvertisingData
+ reverseUUID(base_uuid, base_uuid_rev);
+ blenano.accumulateAdvertisingPayload(GapAdvertisingData::COMPLETE_LIST_128BIT_SERVICE_IDS,
+ (uint8_t *)base_uuid_rev, sizeof(base_uuid));
+
+ //Advertising Interval
+ blenano.setAdvertisingInterval(ADVERTISING_INTERVAL);
+
+ //Add Service
+ blenano.addService(myService);
+
+ //Start Advertising
+ blenano.startAdvertising();
+
+ uint8_t buf[2];
+ float tempadt;
+
+ // reset sensor to default values
+ temp.reset();
+
+ // reduce sample rate to save power
+ temp.setConfig(ONE_SPS_MODE);
+
+ //------------------------------------------------------------
+ //Loop
+ //------------------------------------------------------------
+ while(1)
+ {
+ // get temperature every 10 seconds
+ tempadt = temp.getTemp();
+
+ int16_t value0 = tempadt; //Get integer value
+ int16_t value1 = (tempadt - value0)*100; //Get decimal value
+ buf[0] = value0;
+ buf[1] = value1;
+
+ //Send out
+ blenano.updateCharacteristicValue(rxCharacteristic.getValueAttribute().getHandle(), buf, 2);
+
+ blenano.waitForEvent();
+
+ wait(1);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Aug 30 03:35:10 2018 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#0fdfcf7350896a9c0b57c4a18237677abfe25f1a