@@ -111,6 +111,10 @@ RadioSpinel::RadioSpinel(void)
111111#if OPENTHREAD_SPINEL_CONFIG_VENDOR_HOOK_ENABLE
112112 , mVendorRestorePropertiesCallback (nullptr )
113113 , mVendorRestorePropertiesContext (nullptr )
114+ #endif
115+ #if OPENTHREAD_SPINEL_CONFIG_COMPATIBILITY_ERROR_CALLBACK_ENABLE
116+ , mCompatibilityErrorCallback (nullptr )
117+ , mCompatibilityErrorContext (nullptr )
114118#endif
115119 , mTimeSyncEnabled (false )
116120 , mTimeSyncOn (false )
@@ -198,7 +202,7 @@ otError RadioSpinel::CheckSpinelVersion(void)
198202 {
199203 LogCrit (" Spinel version mismatch - Posix:%d.%d, RCP:%d.%d" , SPINEL_PROTOCOL_VERSION_THREAD_MAJOR,
200204 SPINEL_PROTOCOL_VERSION_THREAD_MINOR, versionMajor, versionMinor);
201- DieNow (OT_EXIT_RADIO_SPINEL_INCOMPATIBLE );
205+ HandleCompatibilityError ( );
202206 }
203207
204208exit:
@@ -210,13 +214,13 @@ void RadioSpinel::InitializeCaps(bool &aSupportsRcpApiVersion, bool &aSupportsRc
210214 if (!GetSpinelDriver ().CoprocessorHasCap (SPINEL_CAP_CONFIG_RADIO))
211215 {
212216 LogCrit (" The co-processor isn't a RCP!" );
213- DieNow (OT_EXIT_RADIO_SPINEL_INCOMPATIBLE );
217+ HandleCompatibilityError ( );
214218 }
215219
216220 if (!GetSpinelDriver ().CoprocessorHasCap (SPINEL_CAP_MAC_RAW))
217221 {
218222 LogCrit (" RCP capability list does not include support for radio/raw mode" );
219- DieNow (OT_EXIT_RADIO_SPINEL_INCOMPATIBLE );
223+ HandleCompatibilityError ( );
220224 }
221225
222226 sSupportsLogStream = GetSpinelDriver ().CoprocessorHasCap (SPINEL_CAP_OPENTHREAD_LOG_METADATA);
@@ -251,7 +255,7 @@ otError RadioSpinel::CheckRadioCapabilities(otRadioCaps aRequiredRadioCaps)
251255 }
252256 }
253257
254- DieNow (OT_EXIT_RADIO_SPINEL_INCOMPATIBLE );
258+ HandleCompatibilityError ( );
255259 }
256260
257261exit:
@@ -279,7 +283,7 @@ otError RadioSpinel::CheckRcpApiVersion(bool aSupportsRcpApiVersion, bool aSuppo
279283 LogCrit (" RCP and host are using incompatible API versions" );
280284 LogCrit (" RCP API Version %u is older than min required by host %u" , rcpApiVersion,
281285 SPINEL_MIN_HOST_SUPPORTED_RCP_API_VERSION);
282- DieNow (OT_EXIT_RADIO_SPINEL_INCOMPATIBLE );
286+ HandleCompatibilityError ( );
283287 }
284288 }
285289
@@ -299,7 +303,7 @@ otError RadioSpinel::CheckRcpApiVersion(bool aSupportsRcpApiVersion, bool aSuppo
299303 LogCrit (" RCP and host are using incompatible API versions" );
300304 LogCrit (" RCP requires min host API version %u but host is older and at version %u" , minHostRcpApiVersion,
301305 SPINEL_RCP_API_VERSION);
302- DieNow (OT_EXIT_RADIO_SPINEL_INCOMPATIBLE );
306+ HandleCompatibilityError ( );
303307 }
304308 }
305309
@@ -2395,5 +2399,24 @@ otError RadioSpinel::SetChannelTargetPower(uint8_t aChannel, int16_t aTargetPowe
23952399}
23962400#endif // OPENTHREAD_CONFIG_PLATFORM_POWER_CALIBRATION_ENABLE
23972401
2402+ #if OPENTHREAD_SPINEL_CONFIG_COMPATIBILITY_ERROR_CALLBACK_ENABLE
2403+ void RadioSpinel::SetCompatibilityErrorCallback (otRadioSpinelCompatibilityErrorCallback aCallback, void *aContext)
2404+ {
2405+ mCompatibilityErrorCallback = aCallback;
2406+ mCompatibilityErrorContext = aContext;
2407+ }
2408+ #endif
2409+
2410+ void RadioSpinel::HandleCompatibilityError (void )
2411+ {
2412+ #if OPENTHREAD_SPINEL_CONFIG_COMPATIBILITY_ERROR_CALLBACK_ENABLE
2413+ if (mCompatibilityErrorCallback )
2414+ {
2415+ mCompatibilityErrorCallback (mCompatibilityErrorContext );
2416+ }
2417+ #endif
2418+ DieNow (OT_EXIT_RADIO_SPINEL_INCOMPATIBLE);
2419+ }
2420+
23982421} // namespace Spinel
23992422} // namespace ot
0 commit comments