Skip to content

Commit

Permalink
Merge pull request #11 from I-SYST/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
hnhoan authored Mar 5, 2017
2 parents 5d76681 + 5c93879 commit 6e572c6
Show file tree
Hide file tree
Showing 12 changed files with 485 additions and 153 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*--------------------------------------------------------------------------
File : ble_periph_app.h
File : ble_app.h
Author : Hoang Nguyen Hoan Dec 26, 2016
Expand Down Expand Up @@ -31,8 +31,8 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Modified by Date Description
----------------------------------------------------------------------------*/
#ifndef __BLE_PERIPH_APP_H__
#define __BLE_PERIPH_APP_H__
#ifndef __BLE_APP_H__
#define __BLE_APP_H__

#include <stdint.h>

Expand Down Expand Up @@ -66,20 +66,29 @@ typedef enum {
#define BLEAPP_INFOSTR_MAX_SIZE 20

typedef void (*PRIVINITCB)();
typedef void (*BLEEVTHANDLER)(ble_evt_t *pEvt);

#pragma pack(push, 4)

typedef struct _BleAppDevInfo {
const char ModelName[16]; // Model name
const char ManufName[16]; // Manufacturer name
const char *pSerialNoStr;// Serial number string
const char *pFwVerStr; // Firmware version string
const char *pHwVerStr; // Hardware version string
} BLEAPP_DEVDESC;

typedef struct _BleAppConfig {
nrf_clock_lf_cfg_t ClkCfg;
BLEAPP_MODE AppMode;
nrf_clock_lf_cfg_t ClkCfg; // Clock config
int CentLinkCount; // Number of central link
int PeriLinkCount; // Number of peripheral link
BLEAPP_MODE AppMode; // App use scheduler, rtos
const char *pDevName; // Device name
const char *pModelName; // Model name
const char *pManufName; // Manufacturer name
const char *pSerialNoStr; // Serial number string
const char *pFwVerStr; // Firmware version string
const char *pHwVerStr; // Hardware version string
uint16_t VendorID; // PnP Bluetooth/USB vendor id
uint16_t ProductId; // PnP Product ID
uint16_t ProductId; // PnP product ID
uint16_t ProductVer; // PnP product version
bool bEnDevInfoService; // Enable device information service (DIS)
const BLEAPP_DEVDESC *pDevDesc; // Pointer device info descriptor
const uint8_t *pManData; // Manufacture specific data to advertise
int ManDataLen; // Length of manufacture specific data
BLEAPP_SECTYPE SecType; // Secure connection type
Expand All @@ -90,35 +99,64 @@ typedef struct _BleAppConfig {
uint32_t AdvTimeout; // In sec
uint32_t AdvSlowInterval; // Slow advertising interval, if > 0, fallback to
// slow interval on adv timeout and advertise until connected
int ConnLedPort;
int ConnLedPort; // Connection LED port & pin number
int ConnLedPin;
uint32_t (*SDEvtHandler)(void) ; // Require for BLEAPP_MODE_RTOS
uint32_t (*SDEvtHandler)(void) ;// Require for BLEAPP_MODE_RTOS
} BLEAPP_CFG;

#pragma pack(pop)

#ifdef __cplusplus

class BleApp {
public:
virtual bool Init(BLEAPP_CFG &CfgData);

virtual void InitCustomData() = 0;
virtual void InitServices() = 0;
virtual void SrvcEvtDispatch(ble_evt_t * p_ble_evt) = 0;

virtual void ProcessEvt();
virtual void EnterDfu();
virtual void Start();

private:
};

extern "C" {
#endif


// ***
// Require implementations per app
// Implementations per app as require
//
void BlePeriphAppInitUserData();
void BlePeriphAppInitServices();
void BlePeriphAppSrvcEvtDispatch(ble_evt_t * p_ble_evt);
void BleAppInitUserData();
void BleAppInitUserServices();
void BlePeriphEvtUserHandler(ble_evt_t * p_ble_evt);
void BleCentralEvtUserHandler(ble_evt_t * p_ble_evt);

//*** Require implementation if app operating mode is BLEAPP_MODE_RTOS
// This function should normal wait for RTOS to signal an event on sent by
// Softdevice
void BleAppRtosWaitEvt(void);

/**
* BLE App initialization
* @brief BLE main App initialization
*
* @param pBleAppCfg : Pointer to app configuration data
* @param bEraseBond : true to force erase all bonding info
*
* @return true - success
*/
bool BlePeriphAppInit(const BLEAPP_CFG *pBleAppCfg, bool bEraseBond);
void BlePeriphAppProcessEvt();
void BlePeriphAppEnterDfu();
void BlePeriphAppStart();
bool BleAppInit(const BLEAPP_CFG *pBleAppCfg, bool bEraseBond);
void BleAppProcessEvt();
void BleAppEnterDfu();
void BleAppStart();
uint16_t BleAppGetConnHandle();

#ifdef __cplusplus
}
#endif

#endif // __BLE_PERIPH_APP_H__
#endif // __BLE_APP_H__

13 changes: 13 additions & 0 deletions ARM/Nordic/include/blueio_blesrvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Modified by Date Description
#define __BLUEIO_BLESRVC_H__

#include "ble_srv_common.h"
#include "serialintrf.h"

// Default BlueIO UUID. User should use privately generated UUID
// UUID : 00000000-287c-11e4-ab74-0002a5d5c51b
Expand All @@ -54,11 +55,20 @@ Modified by Date Description
#define BLUEIOSVC_CHAR_PROP_NOTIFY (1<<1)
#define BLUEIOSVC_CHAR_PROP_WRITEWORESP (1<<2)
#define BLUEIOSVC_CHAR_PROP_WRITE (1<<3)
#define BLUEIOSVC_CHAR_PROP_VARLEN (1<<4)

typedef struct __BlueIOBLEService BLUEIOSRVC;

/**
* Callback on write
*/
typedef void (*BLUEIOSRVC_WRCB) (BLUEIOSRVC *pBlueIOSvc, uint8_t *pData, int Offset, int Len);

/**
* Callback on set notification
*/
typedef void (*BLUEIOSRVC_SETNOTCB)(BLUEIOSRVC *pBlueIOSvc, bool bEnable);

// Service connection security types
typedef enum {
BLUEIOSRVC_SECTYPE_NONE, // open, no security
Expand All @@ -78,6 +88,9 @@ typedef struct {
const char *pDesc; // char UTF-8 description string
BLUEIOSRVC_WRCB WrCB; // Callback for write char, set to NULL for read char
bool bNotify; // Notify flag for read characteristic
BLUEIOSRVC_SETNOTCB SetNotifCB; // Callback on set notification
uint8_t *pDefValue; // pointer to char default values
uint16_t ValueLen; // Default value length in bytes
ble_gatts_char_handles_t Hdl; // char handle
} BLUEIOSRVC_CHAR;

Expand Down
23 changes: 19 additions & 4 deletions ARM/Nordic/nRF51/EHAL/.project
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<locationURI>PARENT-3-WORKSPACE_LOC/include/base64.h</locationURI>
</link>
<link>
<name>include/ble_periph_app.h</name>
<name>include/ble_app.h</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/include/ble_periph_app.h</locationURI>
<locationURI>PARENT-2-PROJECT_LOC/include/ble_app.h</locationURI>
</link>
<link>
<name>include/blueio_blesrvc.h</name>
Expand All @@ -50,6 +50,11 @@
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/include/blueio_board.h</locationURI>
</link>
<link>
<name>include/bme280.h</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/include/bme280.h</locationURI>
</link>
<link>
<name>include/cfifo.h</name>
<type>1</type>
Expand Down Expand Up @@ -100,6 +105,11 @@
<type>1</type>
<locationURI>PARENT-3-PROJECT_LOC/include/idelay.h</locationURI>
</link>
<link>
<name>include/idevice.h</name>
<type>1</type>
<locationURI>PARENT-4-PROJECT_LOC/include/idevice.h</locationURI>
</link>
<link>
<name>include/intelhex.h</name>
<type>1</type>
Expand Down Expand Up @@ -206,9 +216,14 @@
<locationURI>PARENT-4-PROJECT_LOC/src/base64.c</locationURI>
</link>
<link>
<name>src/ble_periph_app.cpp</name>
<name>src/ble_app.cpp</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/src/ble_app.cpp</locationURI>
</link>
<link>
<name>src/ble_app_handler.c</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/src/ble_periph_app.cpp</locationURI>
<locationURI>PARENT-2-PROJECT_LOC/src/ble_app_handler.c</locationURI>
</link>
<link>
<name>src/blueio_blesrvc.c</name>
Expand Down
25 changes: 15 additions & 10 deletions ARM/Nordic/nRF52/EHAL/.project
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
<locationURI>PARENT-4-PROJECT_LOC/include/base64.h</locationURI>
</link>
<link>
<name>include/ble_periph_app.h</name>
<name>include/ble_app.h</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/include/ble_periph_app.h</locationURI>
<locationURI>PARENT-2-PROJECT_LOC/include/ble_app.h</locationURI>
</link>
<link>
<name>include/blueio_blesrvc.h</name>
Expand Down Expand Up @@ -216,9 +216,14 @@
<locationURI>PARENT-4-PROJECT_LOC/src/base64.c</locationURI>
</link>
<link>
<name>src/ble_periph_app.cpp</name>
<name>src/ble_app.cpp</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/src/ble_periph_app.cpp</locationURI>
<locationURI>PARENT-2-PROJECT_LOC/src/ble_app.cpp</locationURI>
</link>
<link>
<name>src/ble_app_handler.c</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/src/ble_app_handler.c</locationURI>
</link>
<link>
<name>src/blueio_blesrvc.c</name>
Expand Down Expand Up @@ -295,6 +300,11 @@
<type>2</type>
<locationURI>virtual:/virtual</locationURI>
</link>
<link>
<name>src/nrf_log_backend_printf.c</name>
<type>1</type>
<locationURI>PARENT-2-PROJECT_LOC/src/nrf_log_backend_printf.c</locationURI>
</link>
<link>
<name>src/prbs.c</name>
<type>1</type>
Expand Down Expand Up @@ -600,11 +610,6 @@
<type>2</type>
<locationURI>virtual:/virtual</locationURI>
</link>
<link>
<name>src/nRF5_SDK_12/libraries/sha256</name>
<type>2</type>
<locationURI>virtual:/virtual</locationURI>
</link>
<link>
<name>src/nRF5_SDK_12/libraries/svc</name>
<type>2</type>
Expand Down Expand Up @@ -1033,7 +1038,7 @@
<link>
<name>src/nRF5_SDK_12/libraries/sha256/sha256.c</name>
<type>1</type>
<locationURI>PARENT-5-PROJECT_LOC/external/nRF5_SDK_12/components/libraries/sha256/sha256.c</locationURI>
<locationURI>$%7BPARENT-5-PROJECT_LOC%7D/external/nRF5_SDK_12/components/libraries/sha256/sha256.c</locationURI>
</link>
<link>
<name>src/nRF5_SDK_12/libraries/svc/nrf_svc_handler.c</name>
Expand Down
4 changes: 2 additions & 2 deletions ARM/Nordic/nRF52/EHAL/src/sdk_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3573,7 +3573,7 @@
// <e> NRF_LOG_ENABLED - nrf_log - Logging
//==========================================================
#ifndef NRF_LOG_ENABLED
#define NRF_LOG_ENABLED 1
#define NRF_LOG_ENABLED 0
#endif
#if NRF_LOG_ENABLED
// <e> NRF_LOG_USES_COLORS - If enabled then ANSI escape code for colors is prefixed to every string
Expand Down Expand Up @@ -3650,7 +3650,7 @@
// <i> Log data is buffered and can be processed in idle.
//==========================================================
#ifndef NRF_LOG_DEFERRED
#define NRF_LOG_DEFERRED 1
#define NRF_LOG_DEFERRED 0
#endif
#if NRF_LOG_DEFERRED
// <o> NRF_LOG_DEFERRED_BUFSIZE - Size of the buffer for logs in words.
Expand Down
Loading

0 comments on commit 6e572c6

Please sign in to comment.