simpleBlePeripheral/source/simpleBLEPeripheral.c
/*********************************************************************
 * @fn      peripheralStateNotificationCB
 *
 * @brief   Notification from the profile of a state change.
 *
 * @param   newState - new state
 *
 * @return  none
 */
@fn      peripheralStateNotificationCB
@brief   Notification from the profile of a state change.

@param   newState - new state

@return  none
@fn peripheralStateNotificationCB @brief Notification from the profile of a state change . @param newState - new state @return none
static void peripheralStateNotificationCB(gaprole_States_t newState)
{
    gaprole_States_t g_gap_state_last = g_gap_state;
    g_gap_state = newState;
    switch (newState)
    {
        case GAPROLE_STARTED: {
			HCI_ReadBDADDRCmd();
			osal_set_event(simpleBLEPeripheral_TaskID, SBP_RESET_ADV_EVT);
        } break;
        case GAPROLE_ADVERTISING: {
         } break;
        case GAPROLE_CONNECTED: {
            osal_set_event(simpleBLEPeripheral_TaskID, SBP_TUYA_BLE_CONN_EVT);
        } break;
        case GAPROLE_WAITING:
        case GAPROLE_WAITING_AFTER_TIMEOUT: {
            if(g_gap_state_last == GAPROLE_CONNECTED) {
                osal_set_event(simpleBLEPeripheral_TaskID, SBP_TUYA_BLE_DISCONN_EVT);
            }
            else if(g_gap_state_last == GAPROLE_ADVERTISING) {
                extern volatile bool g_is_restart_adv;
                if(g_is_restart_adv) {
                    g_is_restart_adv = false;
                    ty_ble_start_adv();
                }
            }
        } break;
        default: {
        } break;
    }
}
static void peripheralStateNotificationCB ( gaprole_States_t newState ) { gaprole_States_t g_gap_state_last = g_gap_state ; g_gap_state = newState ; switch ( newState ) { case GAPROLE_STARTED : { HCI_ReadBDADDRCmd ( ) ; osal_set_event ( simpleBLEPeripheral_TaskID , SBP_RESET_ADV_EVT ) ; } break ; case GAPROLE_ADVERTISING : { } break ; case GAPROLE_CONNECTED : { osal_set_event ( simpleBLEPeripheral_TaskID , SBP_TUYA_BLE_CONN_EVT ) ; } break ; case GAPROLE_WAITING : case GAPROLE_WAITING_AFTER_TIMEOUT : { if ( g_gap_state_last == GAPROLE_CONNECTED ) { osal_set_event ( simpleBLEPeripheral_TaskID , SBP_TUYA_BLE_DISCONN_EVT ) ; } else if ( g_gap_state_last == GAPROLE_ADVERTISING ) { extern volatile bool g_is_restart_adv ; if ( g_is_restart_adv ) { g_is_restart_adv = false ; ty_ble_start_adv ( ) ; } } } break ; default : { } break ; } }
@fn      peripheralStateNotificationCB
 @brief   Notification from the profile of a state change.
@fn peripheralStateNotificationCB @brief Notification from the profile of a state change .