Skip to content

Commit 514374d

Browse files
committed
[posix] add callback for coprocessor reset failure
1 parent 3cff783 commit 514374d

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

script/check-posix-build-cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ main()
7676
fi
7777

7878
reset_source
79-
build -DOT_POSIX_RCP_VENDOR_BUS=ON "$@"
79+
build -DOT_POSIX_RCP_VENDOR_BUS=ON -DOT_POSIX_CP_RESET_FAIL_CALLBACK=ON "$@"
8080
}
8181

8282
main "$@"

src/posix/platform/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ if(OT_POSIX_RCP_VENDOR_BUS)
105105
)
106106
endif()
107107

108+
option(OT_POSIX_CP_RESET_FAIL_CALLBACK "enable co-processor reset failure callback" OFF)
109+
if(OT_POSIX_CP_RESET_FAIL_CALLBACK)
110+
target_compile_definitions(ot-posix-config
111+
INTERFACE "OPENTHREAD_SPINEL_CONFIG_COPROCESSOR_RESET_FAILURE_CALLBACK_ENABLE=1"
112+
)
113+
endif()
114+
108115
set(OT_POSIX_NAT64_CIDR "192.168.255.0/24" CACHE STRING "NAT64 CIDR for OpenThread NAT64")
109116
if(OT_POSIX_NAT64_CIDR)
110117
target_compile_definitions(ot-posix-config

src/posix/platform/platform-posix.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,13 @@ void platformResolverUpdateFdSet(otSysMainloopContext *aContext);
435435
*/
436436
void platformResolverProcess(const otSysMainloopContext *aContext);
437437

438+
/**
439+
* The callback for coprocessor reset failure.
440+
*
441+
* @param[in] aContext A pointer to the mainloop context.
442+
*/
443+
void platformCoprocessorResetFailed(void *aContext);
444+
438445
#ifdef __cplusplus
439446
}
440447
#endif

src/posix/platform/radio.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,21 @@ void Radio::Init(const char *aUrl)
107107
resetRadio = !mRadioUrl.HasParam("no-reset");
108108
skipCompatibilityCheck = mRadioUrl.HasParam("skip-rcp-compatibility-check");
109109

110+
#if OPENTHREAD_SPINEL_CONFIG_COPROCESSOR_RESET_FAILURE_CALLBACK_ENABLE
111+
GetSpinelDriver().SetCoprocessorResetFailureCallback(platformCoprocessorResetFailed, this);
112+
#endif
113+
110114
mRadioSpinel.SetCallbacks(callbacks);
111115
mRadioSpinel.Init(skipCompatibilityCheck, resetRadio, &GetSpinelDriver(),
112116
(skipCompatibilityCheck ? 0 : kRequiredRadioCaps), aEnableRcpTimeSync);
113117

114118
ProcessRadioUrl(mRadioUrl);
115119
}
116120

121+
#if OPENTHREAD_SPINEL_CONFIG_COPROCESSOR_RESET_FAILURE_CALLBACK_ENABLE
122+
OT_TOOL_WEAK void platformCoprocessorResetFailed(void *) {}
123+
#endif
124+
117125
void Radio::Deinit(void)
118126
{
119127
mRadioSpinel.Deinit();

0 commit comments

Comments
 (0)