@@ -94,31 +94,45 @@ class BouffaloButton final : public Button
94
94
class BouffaloDevice final : public Device
95
95
{
96
96
public:
97
- pw::Status Reboot (const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override
97
+ pw::Status Reboot (const chip_rpc_RebootRequest & request, pw_protobuf_Empty & response) override
98
98
{
99
- if (! mRebootTimer )
99
+ if (mRebootTimer )
100
100
{
101
- mRebootTimer =
102
- xTimerCreateStatic (" Reboot" , kRebootTimerPeriodTicks , false , nullptr , RebootHandler, &mRebootTimerBuffer );
103
- xTimerStart (mRebootTimer , 0 );
101
+ return pw::Status::Unavailable ();
104
102
}
103
+
104
+ TickType_t delayMs = kRebootTimerPeriodMs ;
105
+ if (request.delay_ms != 0 )
106
+ {
107
+ delayMs = request.delay_ms ;
108
+ }
109
+ else
110
+ {
111
+ ChipLogProgress (NotSpecified, " Did not receive a reboot delay. Defaulting to %d ms" ,
112
+ static_cast <int >(kRebootTimerPeriodMs ));
113
+ }
114
+ mRebootTimer = xTimerCreateStatic (" Reboot" , pdMS_TO_TICKS (delayMs), false , nullptr , RebootHandler, &mRebootTimerBuffer );
115
+ xTimerStart (mRebootTimer , 0 );
105
116
return pw::OkStatus ();
106
117
}
107
118
108
119
pw::Status FactoryReset (const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override
109
120
{
110
- if (! mRebootTimer )
121
+ if (mRebootTimer )
111
122
{
112
- mRebootTimer = xTimerCreateStatic (" FactoryReset" , kRebootTimerPeriodTicks , false , nullptr , FactoryResetHandler,
113
- &mRebootTimerBuffer );
114
- xTimerStart (mRebootTimer , 0 );
123
+ return pw::Status::Unavailable ();
115
124
}
125
+
126
+ // Notice: reboot delay not configurable here
127
+ mRebootTimer = xTimerCreateStatic (" FactoryReset" , pdMS_TO_TICKS (kRebootTimerPeriodMs ), false , nullptr , FactoryResetHandler,
128
+ &mRebootTimerBuffer );
129
+ xTimerStart (mRebootTimer , 0 );
116
130
return pw::OkStatus ();
117
131
}
118
132
119
133
private:
120
- static constexpr TickType_t kRebootTimerPeriodTicks = 1000 ;
121
- TimerHandle_t mRebootTimer ;
134
+ static constexpr uint32_t kRebootTimerPeriodMs = 1000 ;
135
+ TimerHandle_t mRebootTimer = 0 ;
122
136
StaticTimer_t mRebootTimerBuffer ;
123
137
124
138
static void RebootHandler (TimerHandle_t) { bl_sys_reset_por (); }
0 commit comments