@@ -808,20 +808,54 @@ class XBeeWithCallbacks : public XBee {
808808 /* *
809809 * Register a packet error callback. It is called whenever an
810810 * error occurs in the packet reading process. Arguments to the
811- * callback will be the error code and the data parameter.
812- * while registering the callback.
811+ * callback will be the error code (as returned by
812+ * XBeeResponse::getErrorCode()) and the data parameter. while
813+ * registering the callback.
813814 */
814815 void onPacketError (void (*func)(uint8_t , uintptr_t ), uintptr_t data = 0) { _onPacketError.set (func, data); }
815816
816817 /* *
817818 * Register a response received callback. It is called whenever
818- * a response was succesfully received.
819+ * a response was succesfully received, before a response
820+ * specific callback (or onOtherResponse) below is called.
819821 *
820822 * Arguments to the callback will be the received response and
821823 * the data parameter passed while registering the callback.
822824 */
823825 void onResponse (void (*func)(XBeeResponse&, uintptr_t ), uintptr_t data = 0) { _onResponse.set (func, data); }
824826
827+ /* *
828+ * Register an other response received callback. It is called
829+ * whenever a response was succesfully received, but no response
830+ * specific callback was registered using the functions below
831+ * (after the onResponse callback is called).
832+ *
833+ * Arguments to the callback will be the received response and
834+ * the data parameter passed while registering the callback.
835+ */
836+ void onOtherResponse (void (*func)(XBeeResponse&, uintptr_t ), uintptr_t data = 0) { _onOtherResponse.set (func, data); }
837+
838+ // These functions register a response specific callback. They
839+ // are called whenever a response of the appropriate type was
840+ // succesfully received (after the onResponse callback is
841+ // called).
842+ //
843+ // Arguments to the callback will be the received response
844+ // (already converted to the appropriate type) and the data
845+ // parameter passed while registering the callback.
846+ void onZBTxStatusResponse (void (*func)(ZBTxStatusResponse&, uintptr_t ), uintptr_t data = 0) { _onZBTxStatusResponse.set (func, data); }
847+ void onZBRxResponse (void (*func)(ZBRxResponse&, uintptr_t ), uintptr_t data = 0) { _onZBRxResponse.set (func, data); }
848+ void onZBExplicitRxResponse (void (*func)(ZBExplicitRxResponse&, uintptr_t ), uintptr_t data = 0) { _onZBExplicitRxResponse.set (func, data); }
849+ void onZBRxIoSampleResponse (void (*func)(ZBRxIoSampleResponse&, uintptr_t ), uintptr_t data = 0) { _onZBRxIoSampleResponse.set (func, data); }
850+ void onTxStatusResponse (void (*func)(TxStatusResponse&, uintptr_t ), uintptr_t data = 0) { _onTxStatusResponse.set (func, data); }
851+ void onRx16Response (void (*func)(Rx16Response&, uintptr_t ), uintptr_t data = 0) { _onRx16Response.set (func, data); }
852+ void onRx64Response (void (*func)(Rx64Response&, uintptr_t ), uintptr_t data = 0) { _onRx64Response.set (func, data); }
853+ void onRx16IoSampleResponse (void (*func)(Rx16IoSampleResponse&, uintptr_t ), uintptr_t data = 0) { _onRx16IoSampleResponse.set (func, data); }
854+ void onRx64IoSampleResponse (void (*func)(Rx64IoSampleResponse&, uintptr_t ), uintptr_t data = 0) { _onRx64IoSampleResponse.set (func, data); }
855+ void onModemStatusResponse (void (*func)(ModemStatusResponse&, uintptr_t ), uintptr_t data = 0) { _onModemStatusResponse.set (func, data); }
856+ void onAtCommandResponse (void (*func)(AtCommandResponse&, uintptr_t ), uintptr_t data = 0) { _onAtCommandResponse.set (func, data); }
857+ void onRemoteAtCommandResponse (void (*func)(RemoteAtCommandResponse&, uintptr_t ), uintptr_t data = 0) { _onRemoteAtCommandResponse.set (func, data); }
858+
825859 /* *
826860 * Regularly call this method, which ensures that the serial
827861 * buffer is processed and the appropriate callbacks are called.
@@ -846,6 +880,19 @@ class XBeeWithCallbacks : public XBee {
846880
847881 Callback<uint8_t > _onPacketError;
848882 Callback<XBeeResponse&> _onResponse;
883+ Callback<XBeeResponse&> _onOtherResponse;
884+ Callback<ZBTxStatusResponse&> _onZBTxStatusResponse;
885+ Callback<ZBRxResponse&> _onZBRxResponse;
886+ Callback<ZBExplicitRxResponse&> _onZBExplicitRxResponse;
887+ Callback<ZBRxIoSampleResponse&> _onZBRxIoSampleResponse;
888+ Callback<TxStatusResponse&> _onTxStatusResponse;
889+ Callback<Rx16Response&> _onRx16Response;
890+ Callback<Rx64Response&> _onRx64Response;
891+ Callback<Rx16IoSampleResponse&> _onRx16IoSampleResponse;
892+ Callback<Rx64IoSampleResponse&> _onRx64IoSampleResponse;
893+ Callback<ModemStatusResponse&> _onModemStatusResponse;
894+ Callback<AtCommandResponse&> _onAtCommandResponse;
895+ Callback<RemoteAtCommandResponse&> _onRemoteAtCommandResponse;
849896};
850897
851898/* *
0 commit comments