Merge branch 'gattClient' into develop

This commit is contained in:
Rohit Grover 2015-06-17 09:29:47 +01:00
commit 27b54dee36
5 changed files with 19 additions and 38 deletions

View file

@ -80,11 +80,9 @@ static inline void debugger_breakpoint(void)
// Assert Helper
//--------------------------------------------------------------------+
//#ifndef _TEST_
// #define ASSERT_MESSAGE(format, ...)\
// _PRINTF("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
// #define ASSERT_MESSAGE(format, ...) _PRINTF("Assert at %s: %s: %d: " format "\n", __BASE_FILE__, __PRETTY_FUNCTION__, __LINE__, __VA_ARGS__)
//#else
// #define ASSERT_MESSAGE(format, ...)\
// _PRINTF("%d:note: Assert " format "\n", __LINE__, __VA_ARGS__)
// #define ASSERT_MESSAGE(format, ...) _PRINTF("%d:note: Assert " format "\n", __LINE__, __VA_ARGS__)
//#endif
#if CFG_DEBUG == 3

View file

@ -295,6 +295,8 @@ ble_error_t nRF51Gap::disconnect(DisconnectionReason_t reason)
case CONN_INTERVAL_UNACCEPTABLE:
code = BLE_HCI_CONN_INTERVAL_UNACCEPTABLE;
break;
default:
break;
}
/* Disconnect if we are connected to a central device */

View file

@ -116,14 +116,11 @@ public:
}
virtual ble_error_t write(GattClient::WriteOp_t cmd, Gap::Handle_t connHandle, GattAttribute::Handle_t attributeHandle, size_t length, const uint8_t *value) const {
ble_gattc_write_params_t writeParams = {
.write_op = cmd,
// .flags = 0,
.handle = attributeHandle,
.offset = 0,
.len = length,
.p_value = const_cast<uint8_t *>(value),
};
ble_gattc_write_params_t writeParams = { };
writeParams.write_op = cmd;
writeParams.handle = attributeHandle;
writeParams.len = length;
writeParams.p_value = const_cast<uint8_t *>(value);
uint32_t rc = sd_ble_gattc_write(connHandle, &writeParams);
if (rc == NRF_SUCCESS) {

View file

@ -227,10 +227,9 @@ nRF51ServiceDiscovery::CharUUIDDiscoveryQueue::triggerFirst(void)
.uuid = BLE_UUID_CHARACTERISTIC,
.type = BLE_UUID_TYPE_BLE,
};
ble_gattc_handle_range_t handleRange = {
.start_handle = parentDiscoveryObject->characteristics[charIndex].getDeclHandle(),
.end_handle = parentDiscoveryObject->characteristics[charIndex].getDeclHandle() + 1,
};
ble_gattc_handle_range_t handleRange = { };
handleRange.start_handle = parentDiscoveryObject->characteristics[charIndex].getDeclHandle();
handleRange.end_handle = parentDiscoveryObject->characteristics[charIndex].getDeclHandle() + 1;
if (sd_ble_gattc_char_value_by_uuid_read(parentDiscoveryObject->connHandle, &uuid, &handleRange) == NRF_SUCCESS) {
return;
}

View file

@ -34,33 +34,16 @@
#include <stdint.h>
#include <string.h>
/**
* @brief Function for aborting current handler mode and jump to to other application/bootloader.
*
* @details This functions will use the address provide (reset handler) to be executed after
* handler mode is exited. It creates an initial stack to ensure correct reset behavior
* when the reset handler is executed.
* See http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0552a/Babefdjc.html
*
* @param[in] reset_handler Address of the reset handler to be executed when handler mode exits.
*
* @note This function must never be called directly from 'C' but is intended only to be used from
* \ref bootloader_util_reset. This function will never return but issue a reset into
* provided address.
*/
/**
* @brief Function for aborting current application/bootloader jump to to other app/bootloader.
*
* @details This functions will use the address provide to swap the stack pointer and then load
* the address of the reset handler to be executed. It will check current system mode
* @details This functions will use the address provide to swap the stack pointer and then load
* the address of the reset handler to be executed. It will check current system mode
* (thread/handler) and if in thread mode it will reset into other application.
* If in handler mode \ref isr_abort will be executed to ensure correct exit of handler
* If in handler mode \ref isr_abort will be executed to ensure correct exit of handler
* mode and jump into reset handler of other application.
*
* @param[in] start_addr Start address of other application. This address must point to the
* @param[in] start_addr Start address of other application. This address must point to the
initial stack pointer of the application.
*
* @note This function will never return but issue a reset into provided application.
@ -77,7 +60,7 @@ EXC_RETURN_CMD EQU 0xFFFFFFF9 ; EXC_RETURN for ARM Cortex. When loaded to PC t
LDR R6, [R0, #0x04] ; Load Reset handler into register 6.
LDR R2, =MASK_ZEROS ; Load zeros to R2
MRS R3, IPSR ; Load IPSR to R3 to check for handler or thread mode
MRS R3, IPSR ; Load IPSR to R3 to check for handler or thread mode
CMP R2, R3 ; Compare, if 0 then we are in thread mode and can continue to reset handler of bootloader
MOV R0, R6
BNE isr_abort ; If not zero we need to exit current ISR and jump to reset handler of bootloader
@ -108,6 +91,8 @@ static void bootloader_util_reset(uint32_t start_addr)
asm(
".equ MASK_ONES, 0xFFFFFFFF\n\t" /* Ones, to be loaded into register as default value before reset. */
".equ MASK_ZEROS, 0x00000000\n\t" /* Zeros, to be loaded into register as default value before reset. */
".equ xPSR_RESET, 0x21000000\n\t" /* Default value of xPSR after System Reset. */
".equ EXC_RETURN_CMD, 0xFFFFFFF9\n\t" /* EXC_RETURN for ARM Cortex. When loaded to PC the current interrupt service routine (handler mode) willl exit and the stack will be popped. Execution will continue in thread mode. */
"LDR r5, [r0] \n\t" /* Get App initial MSP for bootloader. */
"MSR MSP, r5 \n\t" /* Set the main stack pointer to the applications MSP. */