Skip to content

Commit

Permalink
Improve check when BLE chip is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
cparata committed Feb 17, 2020
1 parent e53282b commit 5d789c6
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/utility/HCISpiTransport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ int HCISpiTransportClass::begin()
delay(300);
} else
{

// BLE chip not supported
return 0;
}

return 1;
Expand All @@ -101,6 +102,11 @@ void HCISpiTransportClass::wait(unsigned long timeout)

int HCISpiTransportClass::available()
{
if(_ble_chip != SPBTLE_RF && _ble_chip !=SPBTLE_1S && _ble_chip !=BLUENRG_M2SP)
{
return 0;
}

if(_read_index != _write_index)
{
return 1;
Expand Down Expand Up @@ -242,9 +248,6 @@ int HCISpiTransportClass::available()
}
}
}
} else
{

}

digitalWrite(_cs_pin, HIGH);
Expand All @@ -268,9 +271,6 @@ int HCISpiTransportClass::available()
{
/* BLE chip was reset: we need to wait for a while */
delay(300);
} else
{

}

/* Now we can update the write index and close the initial phase */
Expand Down Expand Up @@ -330,6 +330,11 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length)
int result = 0;
uint32_t tickstart = millis();

if(_ble_chip != SPBTLE_RF && _ble_chip !=SPBTLE_1S && _ble_chip !=BLUENRG_M2SP)
{
return 0;
}

do
{
if (_ble_chip == SPBTLE_RF)
Expand Down Expand Up @@ -423,9 +428,6 @@ size_t HCISpiTransportClass::write(const uint8_t* data, size_t length)
result = -3;
break;
}
} else
{

}
} while(result < 0);

Expand Down

0 comments on commit 5d789c6

Please sign in to comment.