Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the Simblee-Board #211

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Enables you to create more customized BLE Peripheral's compared to the basic UAR
* [nRF51822](http://redbearlab.com/redbearlab-nrf51822)
* [BLE Nano](http://redbearlab.com/blenano/)
* [RFduino](http://www.rfduino.com) with [Arduino Add-on](https://github.com/RFduino/RFduino)
* [Simblee](https://www.simblee.com/) **Experimental**

**WARNING**: Adafruit nRF51 boards are **NOT** compatible with this library, this includes the [Bluefruit LE UART Friend](https://www.adafruit.com/products/2479), [Bluefruit LE SPI Friend](https://www.adafruit.com/products/2633), [Bluefruit LE Shield](https://www.adafruit.com/products/2746), [Flora Wearable Bluefruit LE Module](https://www.adafruit.com/products/2487), [Feather 32u4 Bluefruit LE](https://www.adafruit.com/products/2829), and [Feather M0 Bluefruit LE](https://www.adafruit.com/products/2995).

Expand All @@ -60,6 +61,7 @@ Enables you to create more customized BLE Peripheral's compared to the basic UAR
| | RedBearLab nRF51822 | -1 (UNUSED) | -1 (UNUSED) | -1 (UNUSED) |
| | BLE Nano | -1 (UNUSED) | -1 (UNUSED) | -1 (UNUSED) |
| | RFduino | -1 (UNUSED) | -1 (UNUSED) | -1 (UNUSED) |
| | Simblee | -1 (UNUSED) | -1 (UNUSED) | -1 (UNUSED) |

## Compatible IDE's and MCU's

Expand Down
8 changes: 4 additions & 4 deletions src/BLEBondStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#ifdef __AVR__
#include <avr/eeprom.h>
#elif defined(__RFduino__)
#elif defined(__RFduino__) || defined(__Simblee__)
#define FLASH_WAIT_READY { \
while (NRF_NVMC->READY == NVMC_READY_READY_Busy) {}; \
}
Expand Down Expand Up @@ -43,7 +43,7 @@ void BLEBondStore::clearData() {
int32_t pageNo = (uint32_t)_flashPageStartAddress / NRF_FICR->CODEPAGESIZE;

while(sd_flash_page_erase(pageNo) == NRF_ERROR_BUSY);
#elif defined(__RFduino__)
#elif defined(__RFduino__) || defined(__Simblee__)

// turn on flash erase enable
NRF_NVMC->CONFIG = (NVMC_CONFIG_WEN_Een << NVMC_CONFIG_WEN_Pos);
Expand Down Expand Up @@ -76,7 +76,7 @@ void BLEBondStore::putData(const unsigned char* data, unsigned int offset, unsig
this->clearData();

while (sd_flash_write((uint32_t*)_flashPageStartAddress, (uint32_t*)data, (uint32_t)length/4) == NRF_ERROR_BUSY);
#elif defined(__RFduino__) // ignores offset
#elif defined(__RFduino__) || defined(__Simblee__) // ignores offset
this->clearData();

// turn on flash write enable
Expand Down Expand Up @@ -111,7 +111,7 @@ void BLEBondStore::getData(unsigned char* data, unsigned int offset, unsigned in
for (unsigned int i = 0; i < length; i++) {
data[i] = eeprom_read_byte((unsigned char *)this->_offset + offset + i + 1);
}
#elif defined(NRF51) || defined(NRF52) || defined(__RFduino__) // ignores offset
#elif defined(NRF51) || defined(NRF52) || defined(__RFduino__) || defined(__Simblee__) // ignores offset
uint32_t *in = this->_flashPageStartAddress;
uint32_t *out = (uint32_t*)data;

Expand Down
2 changes: 1 addition & 1 deletion src/BLEBondStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BLEBondStore
private:
#if defined(__AVR__) || defined(__MK20DX128__) || defined(__MK20DX256__) || defined(__MKL26Z64__)
int _offset;
#elif defined(NRF51)|| defined(NRF52) || defined(__RFduino__)
#elif defined(NRF51)|| defined(NRF52) || defined(__RFduino__) || defined(__Simblee__)
uint32_t* _flashPageStartAddress;
#endif
};
Expand Down
2 changes: 1 addition & 1 deletion src/BLEDeviceLimits.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#endif

#if defined(NRF51) || defined(NRF52) || defined(__RFduino__)
#if defined(NRF51) || defined(NRF52) || defined(__RFduino__) || defined(__Simblee__)

#define BLE_ADVERTISEMENT_DATA_MAX_VALUE_LENGTH 26
#define BLE_SCAN_DATA_MAX_VALUE_LENGTH 29
Expand Down
4 changes: 2 additions & 2 deletions src/BLEPeripheral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define DEFAULT_APPEARANCE 0x0000

BLEPeripheral::BLEPeripheral(unsigned char req, unsigned char rdy, unsigned char rst) :
#if defined(NRF51) || defined(NRF52) || defined(__RFduino__)
#if defined(NRF51) || defined(NRF52) || defined(__RFduino__) || defined(__Simblee__)
_nRF51822(),
#else
_nRF8001(req, rdy, rst),
Expand Down Expand Up @@ -42,7 +42,7 @@ BLEPeripheral::BLEPeripheral(unsigned char req, unsigned char rdy, unsigned char

_central(this)
{
#if defined(NRF51) || defined(NRF52) || defined(__RFduino__)
#if defined(NRF51) || defined(NRF52) || defined(__RFduino__) || defined(__Simblee__)
this->_device = &this->_nRF51822;
#else
this->_device = &this->_nRF8001;
Expand Down
6 changes: 3 additions & 3 deletions src/BLEPeripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
#include "BLEService.h"
#include "BLETypedCharacteristics.h"

#if defined(NRF51) || defined(NRF52) || defined(__RFduino__)
#if defined(NRF51) || defined(NRF52) || defined(__RFduino__) || defined(__Simblee__)
#include "nRF51822.h"
#else
#include "nRF8001.h"
#endif

#if defined(NRF51) || defined(NRF52) || defined(__RFduino__)
#if defined(NRF51) || defined(NRF52) || defined(__RFduino__) || defined(__Simblee__)
#define BLE_DEFAULT_REQ -1
#define BLE_DEFAULT_RDY -1
#define BLE_DEFAULT_RST -1
Expand Down Expand Up @@ -130,7 +130,7 @@ class BLEPeripheral : public BLEDeviceEventListener,
private:
BLEDevice* _device;

#if defined(NRF51) || defined(NRF52) || defined(__RFduino__)
#if defined(NRF51) || defined(NRF52) || defined(__RFduino__) || defined(__Simblee__)
nRF51822 _nRF51822;
#else
nRF8001 _nRF8001;
Expand Down
2 changes: 1 addition & 1 deletion src/iBeacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#ifndef _I_BEACON_H_
#define _I_BEACON_H_

#if defined(NRF51) || defined(NRF52) || defined(__RFduino__)
#if defined(NRF51) || defined(NRF52) || defined(__RFduino__) || defined(__Simblee__)

#include "BLEPeripheral.h"
#include "BLEUuid.h"
Expand Down
23 changes: 17 additions & 6 deletions src/nRF51822.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if defined(NRF51) || defined(NRF52) || defined(__RFduino__)
#ifdef __Simblee__ // TODO: Is this actually correct? It's the only way this file compiles for me using the S110 V8 headers.
#define NRF5
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I'd recommend this, better to add the equivalents in future down in the file. In case the nRF5 core updates the S110 version.

#define S110
#endif

#if defined(NRF51) || defined(NRF52) || defined(__RFduino__) || defined(__Simblee__)

#ifdef __RFduino__
#include <utility/RFduino/ble.h>
#include <utility/RFduino/ble_hci.h>
#include <utility/RFduino/nrf_sdm.h>
#elif __Simblee__
#include <utility/Simblee/ble.h>
#include <utility/Simblee/ble_hci.h>
#include <utility/Simblee/nrf_sdm.h>
#elif defined(NRF5) || defined(NRF51_S130)
#include <ble.h>
#include <ble_hci.h>
Expand Down Expand Up @@ -99,7 +108,7 @@ void nRF51822::begin(unsigned char advertisementDataSize,
unsigned char numRemoteAttributes)
{

#ifdef __RFduino__
#if defined(__RFduino__) || defined(__Simblee__)
sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, NULL);
#elif defined(NRF5) && !defined(S110)
#if defined(USE_LFRC)
Expand Down Expand Up @@ -520,6 +529,8 @@ void nRF51822::begin(unsigned char advertisementDataSize,

#ifdef __RFduino__
RFduinoBLE_enabled = 1;
#elif defined(__Simblee__)
SimbleeBLE_enabled = 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

#endif
}

Expand Down Expand Up @@ -1206,7 +1217,7 @@ bool nRF51822::writeRemoteCharacteristic(BLERemoteCharacteristic& characteristic
ble_gattc_write_params_t writeParams;

writeParams.write_op = (this->_remoteCharacteristicInfo[i].properties.write) ? BLE_GATT_OP_WRITE_REQ : BLE_GATT_OP_WRITE_CMD;
#ifndef __RFduino__
#if !defined(__RFduino__) && !defined(__Simblee__)
writeParams.flags = 0;
#endif
writeParams.handle = this->_remoteCharacteristicInfo[i].valueHandle;
Expand Down Expand Up @@ -1254,7 +1265,7 @@ bool nRF51822::subscribeRemoteCharacteristic(BLERemoteCharacteristic& characteri
uint16_t value = (this->_remoteCharacteristicInfo[i].properties.notify ? 0x0001 : 0x002);

writeParams.write_op = BLE_GATT_OP_WRITE_REQ;
#ifndef __RFduino__
#if !defined(__RFduino__) && !defined(__Simblee__)
writeParams.flags = 0;
#endif
writeParams.handle = (this->_remoteCharacteristicInfo[i].valueHandle + 1); // don't discover descriptors for now
Expand Down Expand Up @@ -1290,7 +1301,7 @@ bool nRF51822::unsubcribeRemoteCharacteristic(BLERemoteCharacteristic& character
uint16_t value = 0x0000;

writeParams.write_op = BLE_GATT_OP_WRITE_REQ;
#ifndef __RFduino__
#if !defined(__RFduino__) && !defined(__Simblee__)
writeParams.flags = 0;
#endif
writeParams.handle = (this->_remoteCharacteristicInfo[i].valueHandle + 1); // don't discover descriptors for now
Expand Down Expand Up @@ -1367,7 +1378,7 @@ void nRF51822::requestAddress() {
}

void nRF51822::requestTemperature() {
#ifndef __RFduino__
#if !defined(__RFduino__) && !defined(__Simblee__)
int32_t rawTemperature = 0;

sd_temp_get(&rawTemperature);
Expand Down
3 changes: 3 additions & 0 deletions src/nRF51822.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
#if defined(__RFduino__)
#include <utility/RFduino/ble_gatts.h>
#include <utility/RFduino/ble_gattc.h>
#elif defined(__Simblee__)
#include <utility/Simblee/ble_gatts.h>
#include <utility/Simblee/ble_gattc.h>
#elif defined(NRF5) || defined(NRF51_S130)
#include <ble_gatts.h>
#include <ble_gattc.h>
Expand Down
2 changes: 1 addition & 1 deletion src/nRF8001.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !defined(NRF51) && !defined(NRF52) &&!defined(__RFduino__)
#if !defined(NRF51) && !defined(NRF52) && !defined(__RFduino__) && !defined(__Simblee__)

// #define NRF_8001_DEBUG
// #define NRF_8001_ENABLE_DC_DC_CONVERTER
Expand Down
1 change: 1 addition & 0 deletions src/utility/Simblee/THIS_IS_s110_nrf51_8.0.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It seems like the Simblee is using the S110_V8 Softdevice because these are the only headers, where I can find the peripheral device.
Loading