void FMRadioManager::ScanStart(double callback_id) {
LoggerD("Enter");
+ radio_state_e state;
+ auto err = radio_get_state(radio_instance_, &state);
+ if (RADIO_ERROR_NONE != err) {
+ LoggerE("radio_get_state() failed: %d", err);
+ PostResultFailure(callback_id, GetPlatformResult("radio_get_state", err));
+ return;
+ }
+
+ if (RADIO_STATE_READY != state) {
+ LoggerE("Incorrect radio state");
+ PostResultFailure(callback_id,
+ GetPlatformResult("Incorrect radio state", RADIO_ERROR_INVALID_STATE));
+ return;
+ }
+
RadioScanData* user_data = new RadioScanData(*this);
user_data->callback_id_ = callback_id;
- auto err = radio_set_scan_completed_cb(radio_instance_, ScanCompleteCallback,
+ err = radio_set_scan_completed_cb(radio_instance_, ScanCompleteCallback,
user_data);
if (RADIO_ERROR_NONE != err) {
PostResultFailure(callback_id,