28#define RADAR_RX_PIN 32
29#define RADAR_TX_PIN 33
33#define RADAR_BAUDRATE 256000
80 bool configModeAtTestEnd;
94 for (
int i = 0; i < len; i++) Serial.
print(c);
102 Serial.print(lineChar);
103 Serial.println(lineChar);
104 Serial.print(lineChar);
105 Serial.print(lineChar);
108 Serial.print(lineChar);
109 Serial.println(lineChar);
122template <
typename T,
typename... Args>
123void printOne(
const T& first,
const Args&... rest) {
138 Serial.println(name);
139 if (comment.length() > 0) {
143 Serial.println(comment);
158template <
typename... Args>
159void testEnd(
bool success,
const Args&... commentParts) {
162 char lineChar = success ?
'-' :
'=';
166 Serial.print(lineChar);
167 Serial.print(lineChar);
171 Serial.println(success ?
"Success" :
"Failed");
175 Serial.print(lineChar);
176 Serial.print(lineChar);
177 Serial.print(
" Test duration (ms): ");
180 if constexpr (
sizeof...(commentParts) > 0) {
181 Serial.print(lineChar);
182 Serial.print(lineChar);
192 Serial.print(lineChar);
193 Serial.print(lineChar);
194 Serial.println(
"Failed,due to config mode failure!!!");
195 Serial.print(lineChar);
196 Serial.print(lineChar);
197 Serial.print(
"Config mode must be ");
199 Serial.print(
" after the previous test, but is ");
228template <
typename... Args>
231 Serial.print(elapsed);
246 default:
return "UNKNOWN (Unsupported command result, verify code of lib)";
260 for (
int i = 0; i < 9; i++) {
289 Serial.print(presenceDetected ?
"x" :
".");
318 testStart(
"begin() Test",
"Calling begin() is always the first thing we have to do.");
320 testEnd(
true,
"LD2410Async task started successfully.");
323 testEnd(
false,
"LD2410Async task already running.");
335 testEnd(
true,
"LD2410 has rebooted");
344 testStart(
"rebootAsync() Test",
"First real test is a reboot of the LD2410 to ensure it is in normal operation mode.");
349 testPrint(
"rebootAsync() conmpleted. Expecting callback.");
352 testEnd(
false,
"rebootAsync() has returned false. This should only happen if another async command is pending pending");
371 testPrint(
"Test failed. No normal mode data updates received, ");
373 testPrint(
" Since only engineering mode data was excpected, the test has failed");
375 testEnd(
false,
"Got only engineering mode data instead of normal mode data as expected.");
378 testPrint(
"Test failed. No data updates received ");
379 testEnd(
false,
"No data updates received");
382 testPrint(
"Test failed. Received normal mode and engineering mode data,");
383 testPrint(
" but expected only normal mode data.");
384 testEnd(
false,
"Received a mix of normal mode and engineering mode data, but expected only normal mode data.");
390 testStart(
"Normal Mode Data Receive Test",
"Tests whether the sensor sends data in normal mode");
394 testPrint(
"Callback to get data updates registered with onDetectionDataReceived().");
395 testPrint(
"Counting and checking received data for 10 secs");
420 testStart(
"enableEngineeringModeAsync() Test",
"Enables engineering mode, so we get more detailed detection data");
425 testPrint(
"enableEngineeringModeAsync() conmpleted. Expecting callback.");
428 testEnd(
false,
"enableEngineeringModeAsync() has returned false. This should only happen if another async command is pending pending");
443 testPrint(
"Test failed. No engineering mode data updates received, ");
445 testPrint(
" Since only normal mode data was excpected, the test has failed");
447 testEnd(
false,
"Got only normal mode data instead of engineering mode data as expected.");
450 testPrint(
"Test failed. No data updates received ");
451 testEnd(
false,
"No data updates received");
454 testPrint(
"Test failed. Received engineering mode and normal mode data,");
455 testPrint(
" but expected only engineering mode data.");
456 testEnd(
false,
"Received a mix of engineering mode and normal mode data, but expected only engineering mode data.");
462 testStart(
"Engineering Mode Data Receive Test",
"Tests whether the sensor sends data in engineering mode");
466 testPrint(
"Callback to get data updates registered with onDetectionDataReceived().");
467 testPrint(
"Counting and checking received data for 10 secs");
492 testStart(
"disableEngineeringModeAsync() Test",
"Disables engineering mode.");
497 testPrint(
"disableEngineeringModeAsync() conmpleted. Expecting callback.");
500 testEnd(
false,
"disableEngineeringModeAsync() has returned false. This should only happen if another async command is pending pending");
511 testEnd(
true,
"Config mode has been enabled successfully");
515 testEnd(
false,
"enableConfigModeAsync() reports success, but the LD2410 still sends detection data.");
520 testPrint(
"Waiting a 5 seconds, so we can be sure that we are really in config mode (checking if no data updates are sent).");
541 testStart(
"enableConfigModeAsync() Test",
"Enables config mode, which is required if other commands have to be sent to the LD2410.");
546 testPrint(
"enableConfigModeAsync() conmpleted. Expecting callback.");
549 testEnd(
false,
"enableConfigModeAsync() has returned false. This should only happen if another async command is pending pending");
561 testEnd(
true,
"Config mode is still active as expected");
564 testEnd(
false,
"Config mode has been disabled unexpectedly (we got data updates)");
570 testPrint(
"Config mode is still active according to isConfigModeEnabled().");
571 testPrint(
"Wait 5 secs to check if we receive any detection data (which would indicate that config mode has been disabled)");
577 testEnd(
false,
"Config mode has been disabled according to isConfigModeEnabled().");
594 testStart(
"Config Mode Persistenc Test",
"Checks whther config mode remains active when other commands are sent");
598 testPrint(
"requestFirmwareAsync() started. Waiting for callback (which should not change the config mode state).");
601 testEnd(
false,
"requestFirmwareAsync() has returned false. This should only happen if another async command is pending pending");
613 testEnd(
true,
"Config mode has been disabled successfully");
616 testEnd(
false,
"disableConfigModeAsync() reports success, but the LD2410 does not send detection data (that typically means that config mode is active).");
621 testPrint(
"Waiting a 5 seconds, so we can be sure that config mode has really been disabled (checking if data updates are sent).");
642 testStart(
"disableConfigModeAsync() Test",
"Disables config mode. LD2410 will return to normal data detection.");
647 testPrint(
"disableConfigModeAsync() conmpleted. Expecting callback.");
650 testEnd(
false,
"disableConfigModeAsync() has returned false. This should only happen if another async command is pending pending");
671 testStart(
"disableConfigModeAsync() Test when config mode is already disabled",
"Disables config mode, but config mode is not active. The command detects that config mode is inactive and fires the callback avter a minor (1ms) delay.");
673 testEnd(
false,
"Config mode is enabled. This does not work, when config mode is enabled");
679 testPrint(
"disableConfigModeAsync() conmpleted. Expecting callback.");
682 testEnd(
false,
"disableConfigModeAsync() has returned false. This should only happen if another async command is pending pending");
739 testPrint(
"asyncIsBusy() reported true/busy ",
asyncIsBusyTest_Count,
" times while waiting for the enableConfigModeAsync() command to complete.");
744 testPrint(
"Waiting for disableConfigModeAsync() to complete test.");
747 testEnd(
false,
"disableConfigModeAsync() has returned false. Cant complete asyncIsBusy() test");
765 testStart(
"asyncIsBusyTest() Test",
"Tries to enable config mode and checks for busy while waiting for the ack");
770 testPrint(
"enableConfigModeAsync() started. Checking for asyncIsBusy() while waiting for callback.");
775 testEnd(
false,
"enableConfigModeAsync() has returned false. Cant execute asyncIsBusy() test");
789 testEnd(
true,
"asyncCancel() has successfully canceled the disableConfigModeAsync() command");
800 testPrint(
"Waiting for disableConfigModeAsync() callback to complete test.");
803 testEnd(
false,
"disableConfigModeAsync() has returned false. Cant complete asyncCancel() test");
811 testPrint(
"Calledback reportet CANCELED as expected.");
812 testPrint(
"Will wait 5 secs so the disableConfigModeAsync() used for the test can complete, before we disable config mode again.");
830 testStart(
"asyncCancelTest() Test",
"Tries to enable config mode and cancels command.");
835 testPrint(
"enableConfigModeAsync() started. Checking for asyncCancel() while waiting for callback.");
839 testEnd(
false,
"enableConfigModeAsync() has returned false. Cant execute asyncCancel() test");
852 testEnd(
true,
"requestFirmwareAsync() callback reports success");
860 testStart(
"requestFirmwareAsync() Test");
865 testPrint(
"requestFirmwareAsync() started. Waiting for callback.");
869 testEnd(
false,
"requestFirmwareAsync() has returned false. Cant execute test");
879 testEnd(
true,
"requestBluetoothMacAddressAsync() callback reports success");
887 testStart(
"requestBluetoothMacAddressAsync() Test");
892 testPrint(
"requestBluetoothMacAddressAsync() started. Waiting for callback.");
896 testEnd(
false,
"requestBluetoothMacAddressAsync() has returned false. Cant execute test");
909 testEnd(
false,
"requestDistanceResolutionAsync() callback reports success, but the received data is invalid or no data has been received");
912 testEnd(
true,
"requestDistanceResolutionAsync() callback reports success and valid data has been received");
921 testStart(
"requestDistanceResolutionAsync() Test");
926 testPrint(
"requestDistanceResolutionAsync() started. Waiting for callback.");
930 testEnd(
false,
"requestDistanceResolutionAsync() has returned false. Cant execute test");
947 testEnd(
false,
"Inactivity test has failed. LD2410 did not go back to normal mode inactivity handling.");
951 testEnd(
true,
"Inactivity test has passed. LD2410 has started to send data after inactivity handling.");
958 testPrint(
"LD2410 is now in config mode. Waiting 25 secs to see whether it goes back to detection mode after inactivity timeout (will try cancel without effect first and then try exit config mode).");
977 testEnd(
false,
"Inactivity timeout could not be set correctly");
981 testPrint(
"Inacctivity handling enabled and timeout set to 10 secs");
982 testPrint(
"Will activate config mode, remain sillent and wait to see if sensor goes back to datection mode automatically.");
986 testPrint(
"enableConfigModeAsync() executed. Expecting callback.");
989 testEnd(
false,
"enableConfigModeAsync() has returned false. This should only happen if another async command is pending pending");
1000 testEnd(
true,
"As expected inactivity handling did not kick in an revert sensor to detection mode");
1003 testEnd(
false,
"As expected inactivity handling did not kick in an revert sensor to detection modee, but could not execute disableConfigModeAsync() did not succedd.");
1006 testEnd(
true,
"Disable inactivity handling test has passed. LD2410 has not gone back into detection mode.");
1018 testPrint(
"As expected inactivity handling did not kick in an revert sensor to detection mode.");
1021 testEnd(
false,
"As expected inactivity handling did not kick in an revert sensor to detection mode, but could not execute disableConfigModeAsync() at end of test.");
1025 testEnd(
false,
"Disable inactivity handling test has failed. LD2410 did go back into detection mode.");
1033 testPrint(
"Will wait for 25 secs to see whether the LD2410 goes back to detection mode (it should not do this since inactivity handling is disabled).");
1048 testStart(
"Disable Inactivity Handling Test");
1050 testPrint(
"DIsabling inactivity handling and setting a 10 secs timeout");
1054 testEnd(
false,
"Inactivity handling could not be disabled");
1059 testPrint(
"enableConfigModeAsync() executed. Expecting callback.");
1062 testEnd(
false,
"enableConfigModeAsync() has returned false. This should only happen if another async command is pending pending");
1072 testStart(
"ConfigData Struct Validation Test");
1074 testPrint(
"Initialize new, empty config data struct.");
1077 if (testConfigData.
isValid()) {
1078 testEnd(
false,
"Newly initialized config data struct is valid. This should not be the case.");
1082 testPrint(
"Newly initialized config data struct is not valid as expected.");
1085 testPrint(
"Initialize config data struct with valid values.");
1088 if (!testConfigData.
isValid()) {
1089 testEnd(
false,
"Config data struct is not valid (but has been initialized with values.");
1093 testPrint(
"Config data struct is valid");
1098 if (testConfigData.
isValid()) {
1099 testEnd(
false,
"Config data struct is valid, but lightControl value is NOT_SET (which is invalid)");
1103 testPrint(
"Config data struct with lightControl value NOT_SET is not valid as expected.");
1108 if (testConfigData.
isValid()) {
1109 testEnd(
false,
"Config data struct is valid, but outputControl value is NOT_SET (which is invalid)");
1113 testPrint(
"Config data struct with outputControl value NOT_SET is not valid as expected.");
1118 if (testConfigData.
isValid()) {
1119 testEnd(
false,
"Config data struct is valid, but distanceResolution value is NOT_SET (which is invalid)");
1123 testPrint(
"Config data struct with distanceResolution value NOT_SET is not valid as expected.");
1127 for (
int i = 0; i < 9; i++) {
1129 if (testConfigData.
isValid()) {
1130 testEnd(
false,
"distanceGateMotionSensitivity is out of range, but config data struct is reported as valid");
1136 if (testConfigData.
isValid()) {
1137 testEnd(
false,
"distanceGateStationarySensitivity is out of range, but config data struct is reported as valid");
1143 testPrint(
"Checking distanceGateMotionSensitivity and distanceGateStationarySensitivity with out of range values reported invalid as excpected.");
1147 if (testConfigData.
isValid()) {
1148 testEnd(
false,
"maxMotionDistanceGate is out of range, but config data struct is reported as valid");
1153 if (testConfigData.
isValid()) {
1154 testEnd(
false,
"maxStationaryDistanceGate is out of range, but config data struct is reported as valid");
1159 testEnd(
true,
"Config data struct validation test has passed.");
1172 testEnd(
false,
"requestAllConfigSettingsAsync() callback reports success, but no data has been received or data is invalid.");
1175 testEnd(
true,
"requestAllConfigSettingsAsync() callback reports success and data has been received");
1184 testStart(
"requestAllConfigSettingsAsync() Test");
1190 testPrint(
"requestAllConfigSettingsAsync() started. Waiting for callback.");
1194 testEnd(
false,
"requestAllConfigSettingsAsync() has returned false. Cant execute test");
1205 testStart(
"getConfigData() & getConfigDataRef() Test");
1207 testPrint(
"Getting a clone of the config data struct with getConfigData()");
1209 testPrint(
"The cloned struct has been stored in variable orgConfigData so we can use it to restore the org data at the end of the tests");
1211 testPrint(
"Getting a reference to the config data struct with getConfigDataRef()");
1214 testPrint(
"Check if the are both the same (they should be)");
1216 testEnd(
false,
"getConfigData() test has failed. The two config data structs are not equal.");
1219 testPrint(
"The cloned config data struct and the referenced struct are the same as expected.");
1220 testEnd(
true,
"getConfigData() & getConfigDataRef() test has passed.");
1245 testPrint(
"requestAuxControlSettingsAsync() has returned the expected values");
1246 testEnd(
true,
"configureAuxControlSettingsAsync() and requestAuxControlSettingsAsync() have worked as expected");
1250 testEnd(
false,
"requestAuxControlSettingsAsync() has retuned unexpected value. Either the requesyt command or the configure command did not work as expected.");
1260 testPrint(
"configureAuxControlSettingsAsync() has reported success. Fetch the relevant settings so we can check if they have been configured as expected.");
1264 testPrint(
"requestAuxControlSettingsAsync() started. Waiting for callback.");
1267 testEnd(
false,
"requestAuxControlSettingsAsync() has returned false. Cant execute test");
1276 testStart(
"configureAuxControlSettingsAsync() & requestAuxControlSettingsAsync() Test",
"Tries to change the lightContol, lightThreshold and outputControl config settings und reads back the values");
1289 testPrint(
"configureAuxControlSettingsAsync() started. Waiting for callback.");
1292 testEnd(
false,
"configureAuxControlSettingsAsync() has returned false. Cant execute test");
1315 testPrint(
"requestGateParametersAsync() has returned the expected values");
1316 testEnd(
true,
"configureDistanceGateSensitivityAsync() and requestGateParametersAsync() have worked as expected");
1319 testEnd(
false,
"requestGateParametersAsync() has retuned unexpected values. Either the request command or the configure command did not work as expected.");
1329 testPrint(
"configureDistanceGateSensitivityAsync() has reported success. Fetch the relevant settings so we can check if they have been configured as expected.");
1333 testPrint(
"requestGateParametersAsync() started. Waiting for callback.");
1336 testEnd(
false,
"requestGateParametersAsync() has returned false. Cant execute test");
1345 testStart(
"configureDistanceGateSensitivityAsync() & requestGateParametersAsync() Test",
"Tries to change gate sensitivity parameter config settings und reads back the values");
1358 testPrint(
"configureDistanceGateSensitivityAsync() started. Waiting for callback.");
1361 testEnd(
false,
"configureDistanceGateSensitivityAsync() has returned false. Cant execute test");
1386 testPrint(
"requestGateParametersAsync() has returned the expected values");
1387 testEnd(
true,
"configureMaxGateAndNoOneTimeoutAsync() and requestGateParametersAsync() have worked as expected");
1390 testEnd(
false,
"requestGateParametersAsync() has retuned unexpected values. Either the request command or the configure command did not work as expected.");
1400 testPrint(
"configureMaxGateAndNoOneTimeoutAsync() has reported success. Fetch the relevant settings so we can check if they have been configured as expected.");
1404 testPrint(
"requestGateParametersAsync() started. Waiting for callback.");
1407 testEnd(
false,
"requestGateParametersAsync() has returned false. Cant execute test");
1416 testStart(
"configureMaxGateAndNoOneTimeoutAsync() & requestGateParametersAsync() Test",
"Tries to change max gate parameter and noone timeout config settings und reads back the values");
1429 testPrint(
"configureMaxGateAndNoOneTimeoutAsync() started. Waiting for callback.");
1432 testEnd(
false,
"configureMaxGateAndNoOneTimeoutAsync() has returned false. Cant execute test");
1452 testPrint(
"requestDistanceResolutionAsync() has returned the expected values");
1453 testEnd(
true,
"configureDistanceResolutionAsync() and requestDistanceResolutionAsync() have worked as expected");
1456 testEnd(
false,
"requestDistanceResolutionAsync() has retuned unexpected values. Either the request command or the configure command did not work as expected.");
1466 testPrint(
"configureDistanceResolutionAsync() has reported success. Fetch the relevant settings so we can check if they have been configured as expected.");
1470 testPrint(
"requestDistanceResolutionAsync() started. Waiting for callback.");
1473 testEnd(
false,
"requestDistanceResolutionAsync() has returned false. Cant execute test");
1482 testStart(
"configureDistanceResolutionAsync() & requestDistanceResolutionAsync() Test",
"Tries distance resolution settings and reads back the values");
1493 testPrint(
"configureDistanceResolutionAsync() started. Waiting for callback.");
1496 testEnd(
false,
"configureDistanceResolutionAsync() has returned false. Cant execute test");
1516 testPrint(
"requestAllConfigSettingsAsync() has returned the expected values");
1517 testEnd(
true,
"configureAllConfigSettingsAsync() and requestAllConfigSettingsAsync() have worked as expected");
1520 testEnd(
false,
"requestAllConfigSettingsAsync() has retuned unexpected values. Either the request command or the configure command did not work as expected.");
1530 testPrint(
"configureAllConfigSettingsAsync() has reported success. Fetch the relevant settings so we can check if they have been configured as expected.");
1534 testPrint(
"requestAllConfigSettingsAsync() started. Waiting for callback.");
1537 testEnd(
false,
"requestAllConfigSettingsAsync() has returned false. Cant execute test");
1546 testStart(
"configureAllConfigSettingsAsync() & requestAllConfigSettingsAsync() Test",
"Tries to change all config parameters and reads back the values");
1560 for (
size_t i = 0; i < 9; i++)
1569 testPrint(
"configureAllConfigSettingsAsync() started. Waiting for callback.");
1572 testEnd(
false,
"configureAllConfigSettingsAsync() has returned false. Cant execute test");
1591 testPrint(
"requestAllConfigSettingsAsync() has returned the expected values");
1592 testEnd(
true,
"restoreFactorySettingsAsync() and requestAllConfigSettingsAsync() have worked as expected");
1595 testEnd(
false,
"requestAllConfigSettingsAsync() has returned unexpected values (previous config). Either the request command or more likely the configure command did not work as expected.");
1605 testPrint(
"configureAllConfigSettingsAsync() has reported success. Fetch the relevant settings so we can check if they have been configured as expected.");
1609 testPrint(
"requestAllConfigSettingsAsync() started. Waiting for callback.");
1612 testEnd(
false,
"requestAllConfigSettingsAsync() has returned false. Cant execute test");
1621 testStart(
"restoreFactorySettingsAsync() Test",
"Restores factory settings and checks if the have changed, compared to the previous settings");
1627 testPrint(
"restoreFactorySettingsAsync() started. Waiting for callback.");
1630 testEnd(
false,
"restoreFactorySettingsAsync() has returned false. Cant execute test");
1644 testEnd(
true,
"configureAllConfigSettingsAsync() has reported success. Fetch the relevant settings so we can check if they have been configured as expected.");
1652 testStart(
"Write Back Org Config Data",
"Tries to write back the org config data that was read at the begin of the tests");
1657 testPrint(
"configureAllConfigSettingsAsync() started. Waiting for callback.");
1660 testEnd(
false,
"configureAllConfigSettingsAsync() has returned false. Cant execute test");
1739 Serial.setTxBufferSize(2048);
1741 Serial.begin(115200);
Asynchronous driver class for the LD2410 human presence radar sensor.
bool configureAuxControlSettingsAsync(LD2410Types::LightControl light_control, byte light_threshold, LD2410Types::OutputControl output_control, AsyncCommandCallback callback)
Configures the auxiliary control parameters (light and output pin).
bool requestGateParametersAsync(AsyncCommandCallback callback)
Requests the current gate parameters from the sensor.
void asyncCancel()
Cancels any pending asynchronous command or sequence.
bool configureDistanceResolutionAsync(LD2410Types::DistanceResolution distanceResolution, AsyncCommandCallback callback)
Configures the distance resolution of the radar.
bool rebootAsync(AsyncCommandCallback callback)
Reboots the sensor.
bool begin()
Starts the background task that continuously reads data from the sensor.
AsyncCommandResult
Result of an asynchronous command execution.
@ TIMEOUT
No ACK received within the expected time window.
@ FAILED
Command failed (sensor responded with negative ACK).
@ SUCCESS
Command completed successfully and ACK was received.
@ CANCELED
Command was canceled by the user before completion.
bool configureMaxGateAndNoOneTimeoutAsync(byte maxMovingGate, byte maxStationaryGate, unsigned short noOneTimeout, AsyncCommandCallback callback)
Configures the maximum detection gates and "no-one" timeout on the sensor.
bool requestAllStaticDataAsync(AsyncCommandCallback callback)
Requests all static information from the sensor.
bool restoreFactorySettingsAsync(AsyncCommandCallback callback)
Restores factory settings of the sensor.
bool disableConfigModeAsync(AsyncCommandCallback callback)
Disables config mode on the radar.
bool isConfigModeEnabled() const
Detects if config mode is enabled.
bool configureAllConfigSettingsAsync(const LD2410Types::ConfigData &configToWrite, bool writeAllConfigData, AsyncCommandCallback callback)
Applies a full ConfigData struct to the LD2410.
void enableInactivityHandling()
Convenience method: enables inactivity handling.
bool enableConfigModeAsync(AsyncCommandCallback callback)
Enables config mode on the radar.
void setInactivityTimeoutMs(unsigned long timeoutMs=60000)
Sets the timeout period for inactivity handling.
LD2410Types::ConfigData getConfigData() const
Returns a clone of the current configuration data of the radar.
void disableInactivityHandling()
Convenience method: disables inactivity handling.
bool requestDistanceResolutionAsync(AsyncCommandCallback callback)
Requests the current distance resolution setting from the sensor.
bool asyncIsBusy()
Checks if an asynchronous command is currently pending.
unsigned long getInactivityTimeoutMs() const
Returns the current inactivity handling timeout period.
bool requestFirmwareAsync(AsyncCommandCallback callback)
Requests the firmware version of the sensor.
bool requestBluetoothMacAddressAsync(AsyncCommandCallback callback)
Requests the Bluetooth MAC address.
bool requestAllConfigSettingsAsync(AsyncCommandCallback callback)
Requests all configuration settings from the sensor.
bool configureDistanceGateSensitivityAsync(const byte movingThresholds[9], const byte stationaryThresholds[9], AsyncCommandCallback callback)
Configures sensitivity thresholds for all gates at once.
bool requestAuxControlSettingsAsync(AsyncCommandCallback callback)
Requests the current auxiliary control settings.
void onDetectionDataReceived(DetectionDataCallback callback)
Registers a callback for new detection data.
bool enableEngineeringModeAsync(AsyncCommandCallback callback)
Enables engineering mode.
bool isInactivityHandlingEnabled() const
Returns whether inactivity handling is currently enabled.
const LD2410Types::DetectionData & getDetectionDataRef() const
Access the current detection data without making a copy.
bool disableEngineeringModeAsync(AsyncCommandCallback callback)
Disables engineering mode.
const LD2410Types::ConfigData & getConfigDataRef() const
Access the current config data without making a copy.
OutputControl
Logic level behavior of the auxiliary output pin.
@ NOT_SET
Placeholder for the initial value. Do not use as a config value (it will cause the configuration comm...
@ DEFAULT_HIGH_DETECTED_LOW
Default high, goes LOW when detection occurs.
@ DEFAULT_LOW_DETECTED_HIGH
Default low, goes HIGH when detection occurs.
DistanceResolution
Distance resolution per gate for detection.
@ NOT_SET
Placeholder for the initial value. Do not use as a config value (it will cause the configuration comm...
@ RESOLUTION_20CM
Each gate is about 0.20 m, max range about 1.8 m.
@ RESOLUTION_75CM
Each gate is about 0.75 m, max range about 6 m.
LightControl
Light-dependent control status of the auxiliary output.
@ NOT_SET
Placeholder for the initial value. Do not use as a config value (it will cause the configuration comm...
@ LIGHT_BELOW_THRESHOLD
Condition: light < threshold.
@ LIGHT_ABOVE_THRESHOLD
Condition: light >= threshold.
byte distanceGateStationarySensitivity[9]
Stationary sensitivity values per gate (0-100).
void print() const
Debug helper: print configuration contents to Serial.
byte distanceGateMotionSensitivity[9]
Motion sensitivity values per gate (0-100).
byte maxMotionDistanceGate
Furthest gate used for motion detection.
OutputControl outputControl
Logic configuration of the OUT pin.
bool equals(const ConfigData &other) const
Compares this ConfigData with another for equality.
byte lightThreshold
Threshold for auxiliary light control (0-255).
bool isValid() const
Validates the configuration data for correctness.
LightControl lightControl
Light-dependent auxiliary control mode.
byte maxStationaryDistanceGate
Furthest gate used for stationary detection.
byte numberOfGates
Number of distance gates (2-8). This member is read-only; changing its value will not influence the r...
DistanceResolution distanceResolution
Current distance resolution. A reboot is required to activate changes after configureAllConfigSetting...
unsigned short noOneTimeout
Timeout (seconds) until "no presence" is declared.
Holds the most recent detection data reported by the radar.
bool engineeringMode
True if engineering mode data was received.
void disableEngineeringModeTest()
void enableConfigModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void disableInactivityHandlingTestTimeElapsed()
void requestFirmwareAsyncTest()
void requestDistanceResolutionAsyncTestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void enableConfigModeTestEnd()
void requestAllConfigSettingsAsyncTestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void configureAllSettingsTestConfigureCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void engineeringModeDataReceiveTestEnd()
void enableEngineeringModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void inactivityHandlingTest()
LD2410Types::DistanceResolution distanceResolutionToApply
void restoreFactorySettingsTesttRequestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
int dataUpdateCounter_engineeringModeCount
void normalModeDataReceiveTestEnd()
byte maxMovingGateToApply
void asyncCancelTestDiableConfigMode()
void startDataUpdateCounter()
void configureAllSettingsTest()
void writeBackOrgConfigDataCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void enableEngineeringModeTest()
void restoreFactorySettingsTest()
void engineeringModeDataReceiveTest()
void testEnd(bool success, const Args &... commentParts)
void requestFirmwareAsyncTestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void restoreFactorySettingsTestResetCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void requestAllConfigSettingsAsyncTest()
HardwareSerial RadarSerial(1)
void writeBackOrgConfigData()
void inactivityHandlingTestEnd()
void disableInactivityHandlingTest()
void configureMaxGateAndNoOneTimeoutAsyncTestRequestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void enableConfigModeTestCheckForDataUpdates()
void gateParametersTest()
void asyncCancelCancelCommand()
void gateParametersTestConfigureSingleGateCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void configDataStructValidationTest()
int asyncIsBusyTest_Count
void disableInactivityHandlingTestConfigModeDisabled(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
unsigned long testStartMs
void printOne(const T &value)
void configModePersistenceTestEnd()
void disableConfigModeTestEnd()
void stopDataUpdateCounter()
void testPrint(const Args &... args)
#define RADAR_RX_PIN
Unit Test for most methods of the lib.
int asyncCancelTest_Count
void asyncIsBusyTestEnableConfigModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void distanceResolutionTest()
void asyncIsBusyTestCheckBusy()
byte stationaryThresholdToApply
LD2410Types::ConfigData orgConfigData
void disableInactivityHandlingTestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void disableDisabledConfigModeTest()
void rebootTestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
byte maxStationaryGateToApply
LD2410Async ld2410(RadarSerial)
void asyncCancelTestDisableConfigModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void gateParametersTestRequestGateParametersCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void distanceResolutionTestRequestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void requestDistanceResolutionAsyncTest()
void disableEngineeringModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
LD2410Types::LightControl lightControlToApply
void auxControlSettingsTestConfigureCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void configModePersistenceTest()
void disableConfigModeTestCheckForDataUpdates()
void printLine(char c, int len)
byte movingThresholdToApply
void configureMaxGateAndNoOneTimeoutAsyncTestConfigureCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
short nooneTimeoutToApply
void configureMaxGateAndNoOneTimeoutAsyncTest()
void enableConfigModeTest()
void normalModeDataReceiveTest()
void asyncIsBusyTestDisableConfigModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void configModePersistenceTestCheckConfigMode()
void initializeConfigDataStruct(LD2410Types::ConfigData &configData)
void asyncCancelTestEnableConfigModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void printBigMessage(const String msg, char lineChar=' *')
int dataUpdateCounter_normalModeCount
void distanceResolutionTestConfigureCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void disableConfigModeTest()
void auxControlSettingsTest()
void configModePersistenceTestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void dataUpdateCounterCallback(LD2410Async *sender, bool presenceDetected)
void disableDisabledConfigModeTestDisableConfigModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
LD2410Types::OutputControl outputControlToApply
void dataUpdateCounterReset()
void auxControlSettingsTestRequestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void requestBluetoothMacAddressAsyncTestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void testStart(String name, String comment="")
LD2410Types::ConfigData configDataToApply
void disableConfigModeTestDisableConfigModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void configureAllSettingsTestRequestCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void inactivityHandlingTestEnableConfigModeCallback(LD2410Async *sender, LD2410Async::AsyncCommandResult asyncResult)
void requestBluetoothMacAddressAsyncTest()
byte lightThresholdToApply
String asyncCommandResultToString(LD2410Async::AsyncCommandResult result)