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.
Dependents: nRF8001_SimpleChat nRF8001_SimpleControls mbed_BLE2 mbed_BLEtry2 ... more
Revision 1:e9a412d69201, committed 2014-10-20
- Comitter:
- RedBearLab
- Date:
- Mon Oct 20 14:33:43 2014 +0800
- Parent:
- 0:075ea2812998
- Commit message:
- Delete the unused files
Changed in this revision
examples/SimpleChat/main.cpp | Show diff for this revision Revisions of this file |
readme.md | Show diff for this revision Revisions of this file |
--- a/examples/SimpleChat/main.cpp Fri Oct 17 22:40:32 2014 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/* - -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 BLEController iOS/Android App. - * Type something from the Terminal to send - * to the BLEController App or vice verse. - * Characteristics received from App will print on Terminal. - */ - -// Import libraries -#include "Arduino.h" -#include "BLEPeripheral.h" - -Serial serial(USBTX, USBRX); - -// The SPI construct, REQN and RDYN IO construct should be modified manually -// It depend on the board you are using and the REQN&RDYN configuration on BLE Shield -SPI spi(PTD2, PTD3, PTD1); -DigitalInOut BLE_RDY(PTA13); -DigitalInOut BLE_REQ(PTD5); - -unsigned char buf[16] = {0}; -unsigned char len = 0; - -/*----- BLE Utility -------------------------------------------------------------------------*/ -// create peripheral instance, see pinouts above -BLEPeripheral blePeripheral = BLEPeripheral(&BLE_REQ, &BLE_RDY, NULL); - -// create service -BLEService uartService = BLEService("713d0000503e4c75ba943148f18d941e"); - -// create characteristic -BLECharacteristic txCharacteristic = BLECharacteristic("713d0002503e4c75ba943148f18d941e", BLENotify, 20); -BLECharacteristic rxCharacteristic = BLECharacteristic("713d0003503e4c75ba943148f18d941e", BLEWriteWithoutResponse, 20); -/*--------------------------------------------------------------------------------------------*/ - -int main() -{ - serial.baud(9600); - serial.printf("Serial begin!\r\n"); - -/*----- BLE Utility ---------------------------------------------*/ - // set advertised local name and service UUID - blePeripheral.setLocalName("BLE Shield"); - - blePeripheral.setAdvertisedServiceUuid(uartService.uuid()); - - // add service and characteristic - blePeripheral.addAttribute(uartService); - blePeripheral.addAttribute(rxCharacteristic); - blePeripheral.addAttribute(txCharacteristic); - - // begin initialization - blePeripheral.begin(); -/*---------------------------------------------------------------*/ - - serial.printf("BLE UART Peripheral begin!\r\n"); - - while(1) - { - BLECentral central = blePeripheral.central(); - - if (central) - { - // central connected to peripheral - serial.printf("Connected to central\r\n"); - - while (central.connected()) - { - // central still connected to peripheral - if (rxCharacteristic.written()) - { - unsigned char len = rxCharacteristic.valueLength(); - const unsigned char *val = rxCharacteristic.value(); - serial.printf("didCharacteristicWritten, Length: %d\r\n", len); - unsigned char i = 0; - while(i<len) - { - serial.printf("%d, ",val[i++]); - } - serial.printf("\r\n"); - } - - len = 0; - if(serial.readable()) - { - while( serial.readable() ) - { - buf[len] = serial.getc(); - len++; - delay(20); - } - serial.printf("Received from terminal: %d bytes\r\n", len); - txCharacteristic.setValue((const unsigned char *)buf, len); - len = 0; - } - } - - // central disconnected - serial.printf("Disconnected from central\r\n"); - } - } -}
--- a/readme.md Fri Oct 17 22:40:32 2014 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -# BLE_nRF8001 library # ---- -Lasted update: 2014/10/17 - - -## Welcome to RedBearLab repository ## \ No newline at end of file