Skip to content

Commit bcf281a

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

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
@@ -73,6 +73,10 @@ Radio::Radio(void)
7373
{
7474
}
7575

76+
#if OPENTHREAD_SPINEL_CONFIG_COPROCESSOR_RESET_FAILURE_CALLBACK_ENABLE
77+
OT_TOOL_WEAK void platformCoprocessorResetFailed(void *) {}
78+
#endif
79+
7680
void Radio::Init(const char *aUrl)
7781
{
7882
bool resetRadio;
@@ -107,6 +111,10 @@ void Radio::Init(const char *aUrl)
107111
resetRadio = !mRadioUrl.HasParam("no-reset");
108112
skipCompatibilityCheck = mRadioUrl.HasParam("skip-rcp-compatibility-check");
109113

114+
#if OPENTHREAD_SPINEL_CONFIG_COPROCESSOR_RESET_FAILURE_CALLBACK_ENABLE
115+
GetSpinelDriver().SetCoprocessorResetFailureCallback(platformCoprocessorResetFailed, this);
116+
#endif
117+
110118
mRadioSpinel.SetCallbacks(callbacks);
111119
mRadioSpinel.Init(skipCompatibilityCheck, resetRadio, &GetSpinelDriver(),
112120
(skipCompatibilityCheck ? 0 : kRequiredRadioCaps), aEnableRcpTimeSync);

0 commit comments

Comments
 (0)