after take away irq(), scan & conneect & write is right

This commit is contained in:
Roy
2021-05-10 11:46:26 +08:00
parent 20614206db
commit edf7afa30f
@@ -376,6 +376,7 @@ static bool doWrite = FALSE;
// GATT read/write procedure state
bool procedureInProgress = FALSE;
bool uartProcedureInProgress = FALSE;
// Maximum PDU size (default = 27 octets)
static uint16_t maxPduSize;
@@ -671,7 +672,10 @@ static void SimpleBLECentral_taskFxn(UArg a0, UArg a1)
SimpleBLECentral_startDiscovery();
}
if (procedureInProgress == FALSE) {
if (uartProcedureInProgress == FALSE) {
PIN_setOutputValue(hKeyPins, PIN_MEM_TEST, 1);
int rxBytes = UART_read(uart_handle, UART_rxBuf, 1);
if (rxBytes) {
@@ -702,9 +706,12 @@ static void SimpleBLECentral_taskFxn(UArg a0, UArg a1)
//
flag_notify(EVT_MEM_DECODE_INS);
procedureInProgress = TRUE;
uartProcedureInProgress = TRUE;
}
} else {
PIN_setOutputValue(hKeyPins, PIN_MEM_TEST, 0);
}
}
@@ -906,7 +913,7 @@ static void SimpleBLECentral_processRoleEvent(gapCentralRoleEvent_t *pEvent)
}
}
}
procedureInProgress = FALSE;
uartProcedureInProgress = FALSE;
}
break;
@@ -983,6 +990,7 @@ static void SimpleBLECentral_processRoleEvent(gapCentralRoleEvent_t *pEvent)
state = BLE_STATE_CONNECTED;
connHandle = pEvent->linkCmpl.connectionHandle;
procedureInProgress = TRUE;
uartProcedureInProgress = TRUE;
// If service discovery not performed initiate service discovery
if (charHdl == 0)
@@ -1049,6 +1057,7 @@ static void SimpleBLECentral_processRoleEvent(gapCentralRoleEvent_t *pEvent)
discState = BLE_DISC_STATE_IDLE;
charHdl = 0;
procedureInProgress = FALSE;
uartProcedureInProgress = FALSE;
// Cancel RSSI reads
SimpleBLECentral_CancelRssi(pEvent->linkTerminate.connectionHandle);
@@ -1108,7 +1117,8 @@ static void SimpleBLECentral_handleKeys(uint8_t shift, uint8_t keys)
if(keys & KEY_UART_EN)
{
flag_notify(EVT_MEM_DECODE_INS);
// flag_notify(EVT_MEM_DECODE_INS);
uartProcedureInProgress = FALSE;
}
#ifndef BOOSTXL_CC2650MA
@@ -1130,7 +1140,8 @@ static void SimpleBLECentral_handleKeys(uint8_t shift, uint8_t keys)
if(keys & KEY_UART_EN)
{
flag_notify(EVT_MEM_DECODE_INS);
// flag_notify(EVT_MEM_DECODE_INS);
uartProcedureInProgress = FALSE;
}
#ifndef BOOSTXL_CC2650MA
@@ -1198,7 +1209,8 @@ static void SimpleBLECentral_handleKeys(uint8_t shift, uint8_t keys)
}
if(keys & KEY_UART_EN){
flag_notify(EVT_MEM_DECODE_INS);
// flag_notify(EVT_MEM_DECODE_INS);
uartProcedureInProgress = FALSE;
}
#ifndef BOOSTXL_CC2650MA
@@ -1307,7 +1319,8 @@ static void SimpleBLECentral_handleKeys(uint8_t shift, uint8_t keys)
if(keys & KEY_UART_EN)
{
flag_notify(EVT_MEM_DECODE_INS);
// flag_notify(EVT_MEM_DECODE_INS);
uartProcedureInProgress = FALSE;
}
#ifndef BOOSTXL_CC2650MA
@@ -1602,7 +1615,8 @@ static void SimpleBLECentral_handleKeys(uint8_t shift, uint8_t keys)
if(keys & KEY_UART_EN)
{
flag_notify(EVT_MEM_DECODE_INS);
// flag_notify(EVT_MEM_DECODE_INS);
uartProcedureInProgress = FALSE;
}
break;
}
@@ -1674,7 +1688,8 @@ static void SimpleBLECentral_processGATTMsg(gattMsgEvent_t *pMsg)
// mem_UART_newline();
#endif
}
// procedureInProgress = FALSE;
// procedureInProgress = FALSE;
}
else if ((pMsg->method == ATT_WRITE_RSP) ||
((pMsg->method == ATT_ERROR_RSP) &&
@@ -1751,7 +1766,7 @@ static void SimpleBLECentral_processGATTMsg(gattMsgEvent_t *pMsg)
} // else - in case a GATT message came after a connection has dropped, ignore it.
// Needed only for ATT Protocol messages
procedureInProgress = FALSE;
uartProcedureInProgress = FALSE;
GATT_bm_free(&pMsg->msg, pMsg->method);
}
@@ -2137,6 +2152,7 @@ static void SimpleBLECentral_processGATTDiscEvent(gattMsgEvent_t *pMsg)
char ACK[10] = {4, scanRes, 4, 46, 80, 48, 4};
UART_write(uart_handle, ACK, 10);
procedureInProgress = FALSE;
uartProcedureInProgress = FALSE;
#endif
}
discState = BLE_DISC_STATE_IDLE;