attempt to use notify event to avoid send-ins & notify handle conflict

This commit is contained in:
weiting2
2020-08-20 15:15:55 +08:00
parent 327f45985b
commit 05a59ffd5e
4 changed files with 20 additions and 17 deletions
@@ -132,10 +132,10 @@ static void mem_central_event() {
mem_connection_timeout();
}
// if(flag_mask(EVT_MEM_NOTIFY_HANDLE)){
// flag_disable(EVT_MEM_NOTIFY_HANDLE);
// central_handle_notify();
// }
if(flag_mask(EVT_MEM_NOTIFY_HANDLE)){
flag_disable(EVT_MEM_NOTIFY_HANDLE);
central_handle_notify();
}
}
static Control_Ins ins = INS_IDLE;
@@ -25,8 +25,8 @@ static uint8 mem_sel = 0;
static uint16_t not_counter = 0; // writing counter, increase when notify
static uint16_t not_offset = 0; // writing pointer, current not writing index
//static uint16_t notify_length = 0;
//static uint8_t notify_value[200] = {0};
static uint16_t notify_length = 0;
static uint8_t notify_value[250] = {0};
#define unsafe_memcpy(p, src, len) \
do { \
@@ -66,8 +66,8 @@ static void central_reset(){
static void master_switch_memory();
static void central_handle_notify(uint8_t notify_length, uint8_t *notify_value){
//static void central_handle_notify(uint8_t notify_length, uint8_t *notify_value){
static void central_handle_notify(){
// These code should be executed if we have a real reset PIN
// if (flag_mask(EVT_PIN_RESET)) {
// // ignore all incoming notify;
@@ -1672,18 +1672,21 @@ static void SimpleBLECentral_processGATTMsg(gattMsgEvent_t *pMsg)
else if (pMsg->method == ATT_HANDLE_VALUE_NOTI){
if(procedureInProgress == FALSE){
attHandleValueNoti_t *att_notify = (attHandleValueNoti_t *)(&pMsg->msg);
central_handle_notify(att_notify->len, att_notify->pValue);
// central_handle_notify(att_notify->len, att_notify->pValue);
notify_length = att_notify->len;
for(int i=0 ; i<nameLength ; i++){
notify_value[i] = att_notify->pValue[i];
}
if(!flag_mask(EVT_MEM_NOTIFY_HANDLE)){
flag_notify(EVT_MEM_NOTIFY_HANDLE)
}
}
else{
err_ack[7] = 5;
UART_write(uart_handle, err_ack, 10);
}
// notify_length = att_notify->len;
// for(int i=0 ; i<nameLength ; i++){
// notify_value[i] = att_notify->pValue[i];
// }
// flag_notify(EVT_MEM_NOTIFY_HANDLE)
}
else if (discState != BLE_DISC_STATE_IDLE)
@@ -5,12 +5,12 @@
#define VERSION_DATE_YEAR 20
#define VERSION_DATE_MONTH 8
#define VERSION_DATE_DAY 20
#define VERSION_DATE_HOUR 14
#define VERSION_DATE_MINUTE 40
#define VERSION_DATE_HOUR 15
#define VERSION_DATE_MINUTE 15
// this is NOT the version hash !!
// it's the last version hash
#define VERSION_HASH 0155ce6488032d0b7db4082dc0e6eeb6164c4313
#define VERSION_HASH 327f45985bbd72b00d8c96a2dffc5d38cf9f4e25
#define VERSION_GIT_BRANCH simple_central_ma_pin
#endif