Update API/doc for NFCNDEFCapable

pull/7822/head
Donatien Garnier 2018-08-09 18:07:51 +01:00
parent 3cd3efe9d8
commit 2246535a9f
1 changed files with 35 additions and 20 deletions

View File

@ -36,40 +36,55 @@ namespace nfc {
public: public:
/** /**
* Check if this instance actually supports NDEF content. * Check if this instance actually supports NDEF content.
*
* @return whether NDEF content is supported * @return whether NDEF content is supported
*/ */
virtual bool is_ndef_supported() const { return false; } virtual bool is_ndef_supported() const { return false; }
/** struct NFCNDEFCapableDelegate {
* Set the instance of the parser which should handle incoming NDEF messages. /**
* If set to NULL, incoming NDEF messages will be rejected * Parse a NDEF message.
* @param[in] parser a pointer to the parser to use, or NULL *
*/ * @param[in] buffer a buffer containing the message to parse
void set_ndef_message_parser(ndef::MessageParser* parser) const; * @param[in] size the buffer's size
*/
void parse_ndef_message(const uint8_t* buffer, size_t size) { }
/** /**
* Set the instance of the build which should generate outgoing NDEF messages. * Build a NDEF message.
* If set to NULL, outgoing NDEF messages will not be produced *
* @param[in] builder a pointer to the builder to use, or NULL * @param[in] buffer a mutable buffer in which the message should be stored
*/ * @param[in] capacity the buffer's capacity
void set_ndef_message_builder(ndef::MessageBuilder* builder) const; * @return the number of bytes actually used
*/
size_t build_ndef_message(uint8_t* buffer, size_t capacity) { return 0; }
};
protected: protected:
/** /**
* Get the NDEF message parser to use, or NULL. * Parse a NDEF message.
* @return a pointer to a parser, or NULL *
* @param[in] a buffer containing a NDEF message
*/ */
ndef::MessageParser* ndef_message_parser(); void parse_ndef_message(const ac_buffer_t& buffer);
/** /**
* Get the NDEF message builder to use, or NULL. * Build NDEF message.
* @return a pointer to a builder, or NULL *
* @param[in,out] a buffer builder in which to create the NDEF message.
* The backing buffer is guaranteed to be continuous.
*/ */
ndef::MessageBuilder* ndef_message_builder(); void build_ndef_message(ac_buffer_builder_t& buffer_builder);
/**
* Set the delegate that will receive events generated by this class.
*
* @oaram[in] delegate the delegate instance to use
*/
void set_delegate(Delegate* delegate);
private: private:
ndef::MessageParser* _message_parser; Delegate* _delegate;
ndef::MessageBuilder* _message_builder;
}; };
/** /**