Import Mbed OS hard-float snapshot
This commit is contained in:
174
connectivity/nfc/source/ndef/common/Mime.cpp
Normal file
174
connectivity/nfc/source/ndef/common/Mime.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2018 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "nfc/ndef/common/Mime.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
namespace ndef {
|
||||
namespace common {
|
||||
|
||||
Mime::Mime() :
|
||||
_mime(NULL),
|
||||
_type_size(0),
|
||||
_content_size(0)
|
||||
{ }
|
||||
|
||||
Mime::Mime(
|
||||
const Span<const uint8_t> &mime_type,
|
||||
const Span<const uint8_t> &content
|
||||
) : _mime(new uint8_t[mime_type.size() + content.size()]),
|
||||
_type_size(mime_type.size()),
|
||||
_content_size(content.size())
|
||||
{
|
||||
memcpy(_mime, mime_type.data(), mime_type.size());
|
||||
memcpy(_mime + mime_type.size(), content.data(), content.size());
|
||||
}
|
||||
|
||||
Mime::Mime(const Mime &to_copy) :
|
||||
_mime(new uint8_t[to_copy.mime_size()]),
|
||||
_type_size(to_copy._type_size),
|
||||
_content_size(to_copy._content_size)
|
||||
{
|
||||
memcpy(_mime, to_copy._mime, to_copy.mime_size());
|
||||
}
|
||||
|
||||
Mime::~Mime()
|
||||
{
|
||||
delete[] _mime;
|
||||
}
|
||||
|
||||
Mime &Mime::operator=(const Mime &to_copy)
|
||||
{
|
||||
if (this == &to_copy) {
|
||||
return * this;
|
||||
}
|
||||
|
||||
delete[] _mime;
|
||||
|
||||
_mime = new uint8_t[to_copy.mime_size()];
|
||||
memcpy(_mime, to_copy._mime, to_copy.mime_size());
|
||||
_type_size = to_copy._type_size;
|
||||
_content_size = to_copy._content_size;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Mime::set_mime(
|
||||
const Span<const uint8_t> &mime_type,
|
||||
const Span<const uint8_t> &content
|
||||
)
|
||||
{
|
||||
delete[] _mime;
|
||||
|
||||
_mime = new uint8_t[mime_type.size() + content.size()];
|
||||
memcpy(_mime, mime_type.data(), mime_type.size());
|
||||
memcpy(_mime + mime_type.size(), content.data(), content.size());
|
||||
_type_size = mime_type.size();
|
||||
_content_size = content.size();
|
||||
}
|
||||
|
||||
Span<const uint8_t> Mime::get_mime_type() const
|
||||
{
|
||||
return make_const_Span(_mime, _type_size);
|
||||
}
|
||||
|
||||
Span<const uint8_t> Mime::get_mime_content() const
|
||||
{
|
||||
return make_const_Span(_mime + _type_size, _content_size);
|
||||
}
|
||||
|
||||
bool Mime::append_as_record(
|
||||
MessageBuilder &message_builder,
|
||||
bool is_last_record
|
||||
) const
|
||||
{
|
||||
return message_builder.append_record(
|
||||
RecordType(
|
||||
RecordType::media_type,
|
||||
get_mime_type()
|
||||
),
|
||||
get_mime_content(),
|
||||
is_last_record
|
||||
);
|
||||
}
|
||||
|
||||
size_t Mime::get_record_size() const
|
||||
{
|
||||
return MessageBuilder::compute_record_size(
|
||||
Record(
|
||||
RecordType(
|
||||
RecordType::media_type,
|
||||
get_mime_type()
|
||||
),
|
||||
get_mime_content(),
|
||||
RecordID(),
|
||||
/* chunk */ false,
|
||||
/* last record */ false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void Mime::move_data(
|
||||
uint8_t *mime_record,
|
||||
size_t mime_type_size,
|
||||
size_t mime_content_size
|
||||
)
|
||||
{
|
||||
delete[] _mime;
|
||||
_mime = mime_record;
|
||||
_type_size = mime_type_size;
|
||||
_content_size = mime_content_size;
|
||||
}
|
||||
|
||||
size_t Mime::mime_size() const
|
||||
{
|
||||
return _type_size + _content_size;
|
||||
}
|
||||
|
||||
bool MimeParser::do_parse(const Record &record, Mime &mime)
|
||||
{
|
||||
if (record.type.tnf != RecordType::media_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// A type and a payload should be present
|
||||
if (record.type.value.empty() || record.payload.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// create the buffer
|
||||
size_t type_size = record.type.value.size();
|
||||
size_t content_size = record.payload.size();
|
||||
uint8_t *mime_buffer = new uint8_t[type_size + content_size];
|
||||
|
||||
// copy type
|
||||
memcpy(mime_buffer, record.type.value.data(), type_size);
|
||||
|
||||
// copy content
|
||||
memcpy(mime_buffer + type_size, record.payload.data(), content_size);
|
||||
|
||||
mime.move_data(mime_buffer, type_size, content_size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
} // namespace ndef
|
||||
} // namespace nfc
|
||||
} // namespace mbed
|
||||
124
connectivity/nfc/source/ndef/common/SimpleMessageParser.cpp
Normal file
124
connectivity/nfc/source/ndef/common/SimpleMessageParser.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2018 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "nfc/ndef/common/SimpleMessageParser.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
namespace ndef {
|
||||
namespace common {
|
||||
|
||||
SimpleMessageParser::SimpleMessageParser() :
|
||||
_message_parser(),
|
||||
_record_parser_chain(),
|
||||
_uri_parser(),
|
||||
_text_parser(),
|
||||
_mime_parser(),
|
||||
_delegate(NULL)
|
||||
{
|
||||
// setup the parser chain
|
||||
_record_parser_chain.set_next_parser(&_uri_parser);
|
||||
_record_parser_chain.set_next_parser(&_text_parser);
|
||||
_record_parser_chain.set_next_parser(&_mime_parser);
|
||||
|
||||
// wire event handling
|
||||
_message_parser.set_delegate(this);
|
||||
_uri_parser.set_delegate(this);
|
||||
_text_parser.set_delegate(this);
|
||||
_mime_parser.set_delegate(this);
|
||||
}
|
||||
|
||||
void SimpleMessageParser::set_delegate(Delegate *delegate)
|
||||
{
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
void SimpleMessageParser::parse(const Span<const uint8_t> &data_buffer)
|
||||
{
|
||||
_message_parser.parse(data_buffer);
|
||||
}
|
||||
|
||||
void SimpleMessageParser::add_record_parser(RecordParser *parser)
|
||||
{
|
||||
_record_parser_chain.set_next_parser(parser);
|
||||
}
|
||||
|
||||
void SimpleMessageParser::on_parsing_error(MessageParser::error_t error)
|
||||
{
|
||||
if (_delegate) {
|
||||
_delegate->on_parsing_error(error);
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleMessageParser::on_parsing_started()
|
||||
{
|
||||
if (_delegate) {
|
||||
_delegate->on_parsing_started();
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleMessageParser::on_record_parsed(const Record &record)
|
||||
{
|
||||
bool parsed = _record_parser_chain.parse(record);
|
||||
|
||||
if (!parsed && _delegate) {
|
||||
_delegate->on_unknown_record_parsed(record);
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleMessageParser::on_parsing_terminated()
|
||||
{
|
||||
if (_delegate) {
|
||||
_delegate->on_parsing_terminated();
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleMessageParser::on_record_parsed(
|
||||
const URI &uri,
|
||||
const RecordID &id
|
||||
)
|
||||
{
|
||||
if (_delegate) {
|
||||
_delegate->on_uri_parsed(uri, id);
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleMessageParser::on_record_parsed(
|
||||
const Text &text,
|
||||
const RecordID &id
|
||||
)
|
||||
{
|
||||
if (_delegate) {
|
||||
_delegate->on_text_parsed(text, id);
|
||||
}
|
||||
}
|
||||
|
||||
void SimpleMessageParser::on_record_parsed(
|
||||
const Mime &mime,
|
||||
const RecordID &id
|
||||
)
|
||||
{
|
||||
if (_delegate) {
|
||||
_delegate->on_mime_parsed(mime, id);
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
} // namespace ndef
|
||||
} // namespace nfc
|
||||
} // namespace mbed
|
||||
|
||||
|
||||
208
connectivity/nfc/source/ndef/common/Text.cpp
Normal file
208
connectivity/nfc/source/ndef/common/Text.cpp
Normal file
@@ -0,0 +1,208 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2018 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "nfc/ndef/common/Text.h"
|
||||
|
||||
namespace {
|
||||
static const uint8_t utf16_encoding_bit = (1 << 7);
|
||||
static const uint8_t language_code_size_mask = 0x3F;
|
||||
static const uint8_t header_index = 0;
|
||||
static const uint8_t language_code_index = 1;
|
||||
static const uint8_t header_size = 1;
|
||||
static const uint8_t text_record_type_value[] = { 'T' };
|
||||
}
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
namespace ndef {
|
||||
namespace common {
|
||||
|
||||
Text::Text() :
|
||||
_text_record(NULL),
|
||||
_text_record_size(0)
|
||||
{ }
|
||||
|
||||
Text::Text(const Text &other) :
|
||||
_text_record(other._text_record ? new uint8_t[other._text_record_size] : NULL),
|
||||
_text_record_size(other._text_record_size)
|
||||
{
|
||||
if (_text_record) {
|
||||
memcpy(_text_record, other._text_record, _text_record_size);
|
||||
}
|
||||
}
|
||||
|
||||
Text::Text(
|
||||
encoding_t text_encoding,
|
||||
const Span<const uint8_t> &language_code,
|
||||
const Span<const uint8_t> &text
|
||||
) : _text_record(NULL),
|
||||
_text_record_size(0)
|
||||
{
|
||||
set_text(text_encoding, language_code, text);
|
||||
}
|
||||
|
||||
Text::~Text()
|
||||
{
|
||||
delete[] _text_record;
|
||||
}
|
||||
|
||||
Text &Text::operator=(const Text &other)
|
||||
{
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
_text_record_size = other._text_record_size;
|
||||
|
||||
delete[] _text_record;
|
||||
if (!other._text_record) {
|
||||
_text_record = NULL;
|
||||
} else {
|
||||
_text_record = new uint8_t[_text_record_size];
|
||||
memcpy(_text_record, other._text_record, _text_record_size);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Text::set_text(
|
||||
encoding_t text_encoding,
|
||||
const Span<const uint8_t> &language_code,
|
||||
const Span<const uint8_t> &text
|
||||
)
|
||||
{
|
||||
delete[] _text_record;
|
||||
|
||||
_text_record_size = header_size + language_code.size() + text.size();
|
||||
_text_record = new uint8_t[_text_record_size];
|
||||
|
||||
// build the header
|
||||
_text_record[header_index] = 0;
|
||||
if (text_encoding == UTF16) {
|
||||
_text_record[header_index] |= utf16_encoding_bit;
|
||||
}
|
||||
_text_record[header_index] |= language_code.size();
|
||||
|
||||
// language code
|
||||
memcpy(_text_record + language_code_index, language_code.data(), language_code.size());
|
||||
|
||||
// actual text
|
||||
memcpy(_text_record + language_code_index + language_code.size(), text.data(), text.size());
|
||||
}
|
||||
|
||||
Text::encoding_t Text::get_encoding() const
|
||||
{
|
||||
return (_text_record[header_index] & utf16_encoding_bit) ? UTF16 : UTF8;
|
||||
}
|
||||
|
||||
Span<const uint8_t> Text::get_language_code() const
|
||||
{
|
||||
return make_const_Span(
|
||||
_text_record + language_code_index,
|
||||
_text_record[header_index] & language_code_size_mask
|
||||
);
|
||||
}
|
||||
|
||||
Span<const uint8_t> Text::get_text() const
|
||||
{
|
||||
if (!_text_record) {
|
||||
return Span<const uint8_t>();
|
||||
}
|
||||
|
||||
size_t language_code_size = get_language_code().size();
|
||||
|
||||
return make_const_Span(
|
||||
_text_record + header_size + language_code_size,
|
||||
_text_record_size - header_size - language_code_size
|
||||
);
|
||||
}
|
||||
|
||||
void Text::move_data(uint8_t *text, size_t size)
|
||||
{
|
||||
delete[] _text_record;
|
||||
_text_record = text;
|
||||
_text_record_size = size;
|
||||
}
|
||||
|
||||
bool Text::append_as_record(
|
||||
MessageBuilder &message_builder,
|
||||
bool is_last_record
|
||||
) const
|
||||
{
|
||||
if (!_text_record) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Build the record type
|
||||
RecordType type(
|
||||
RecordType::well_known_type,
|
||||
text_record_type_value
|
||||
);
|
||||
|
||||
// build the record payload
|
||||
RecordPayload payload(_text_record, _text_record_size);
|
||||
return message_builder.append_record(type, payload, is_last_record);
|
||||
}
|
||||
|
||||
size_t Text::get_record_size() const
|
||||
{
|
||||
if (!_text_record) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return MessageBuilder::compute_record_size(
|
||||
Record(
|
||||
RecordType(
|
||||
RecordType::well_known_type,
|
||||
text_record_type_value
|
||||
),
|
||||
RecordPayload(_text_record, _text_record_size),
|
||||
RecordID(),
|
||||
/* chunk */ false,
|
||||
/* last record */ false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
bool TextParser::do_parse(const Record &record, Text &text)
|
||||
{
|
||||
if (record.type.tnf != RecordType::well_known_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// the record type value should be equal to `T`
|
||||
if (record.type.value != make_const_Span(text_record_type_value) ||
|
||||
record.payload.empty()
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// create the buffer
|
||||
size_t text_record_size = record.payload.size();
|
||||
uint8_t *text_record = new uint8_t[text_record_size];
|
||||
memcpy(text_record, record.payload.data(), text_record_size);
|
||||
|
||||
text.move_data(text_record, text_record_size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
} // namespace ndef
|
||||
} // namespace nfc
|
||||
} // namespace mbed
|
||||
191
connectivity/nfc/source/ndef/common/URI.cpp
Normal file
191
connectivity/nfc/source/ndef/common/URI.cpp
Normal file
@@ -0,0 +1,191 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2018 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "nfc/ndef/common/URI.h"
|
||||
|
||||
namespace {
|
||||
static const uint8_t uri_id_code_size = 1;
|
||||
static const uint8_t uri_id_index = 0;
|
||||
static const uint8_t uri_field_index = 1;
|
||||
static const uint8_t uri_record_type_value[] = { 'U' } ;
|
||||
}
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
namespace ndef {
|
||||
namespace common {
|
||||
|
||||
URI::URI() :
|
||||
_uri(NULL),
|
||||
_uri_size(0)
|
||||
{
|
||||
}
|
||||
|
||||
URI::URI(uri_identifier_code_t id, const Span<const uint8_t> &uri_field) :
|
||||
_uri(uri_field.size() ? new uint8_t[uri_id_code_size + uri_field.size()] : NULL),
|
||||
_uri_size(uri_id_code_size + uri_field.size())
|
||||
{
|
||||
if (_uri) {
|
||||
_uri[uri_id_index] = id;
|
||||
memcpy(_uri + uri_field_index, uri_field.data(), uri_field.size());
|
||||
}
|
||||
}
|
||||
|
||||
URI::URI(const URI &other) :
|
||||
_uri(other._uri ? new uint8_t[other._uri_size] : NULL),
|
||||
_uri_size(other._uri_size)
|
||||
{
|
||||
if (_uri) {
|
||||
memcpy(_uri, other._uri, other._uri_size);
|
||||
}
|
||||
}
|
||||
|
||||
URI::~URI()
|
||||
{
|
||||
delete[] _uri;
|
||||
}
|
||||
|
||||
URI &URI::operator=(const URI &other)
|
||||
{
|
||||
delete[] _uri;
|
||||
|
||||
if (!other._uri) {
|
||||
_uri = NULL;
|
||||
_uri_size = 0;
|
||||
} else {
|
||||
_uri = new uint8_t[other._uri_size];
|
||||
_uri_size = other._uri_size;
|
||||
memcpy(_uri, other._uri, other._uri_size);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void URI::set_uri(
|
||||
uri_identifier_code_t id,
|
||||
const Span<const uint8_t> &uri_field
|
||||
)
|
||||
{
|
||||
delete[] _uri;
|
||||
|
||||
if (uri_field.empty()) {
|
||||
_uri = NULL;
|
||||
_uri_size = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
_uri = new uint8_t[uri_id_code_size + uri_field.size()];
|
||||
_uri_size = uri_id_code_size + uri_field.size();
|
||||
_uri[uri_id_index] = id;
|
||||
memcpy(_uri + uri_field_index, uri_field.data(), uri_field.size());
|
||||
}
|
||||
|
||||
URI::uri_identifier_code_t URI::get_id() const
|
||||
{
|
||||
if (!_uri) {
|
||||
return NA;
|
||||
}
|
||||
|
||||
return static_cast<uri_identifier_code_t>(_uri[uri_id_index]);
|
||||
}
|
||||
|
||||
Span<const uint8_t> URI::get_uri_field() const
|
||||
{
|
||||
if (!_uri) {
|
||||
return Span<const uint8_t>();
|
||||
}
|
||||
return make_const_Span(
|
||||
_uri + uri_field_index,
|
||||
_uri_size - uri_id_code_size
|
||||
);
|
||||
}
|
||||
|
||||
bool URI::append_as_record(MessageBuilder &message_builder, bool is_last_record) const
|
||||
{
|
||||
if (!_uri) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Build the record type
|
||||
RecordType type(
|
||||
RecordType::well_known_type,
|
||||
uri_record_type_value
|
||||
);
|
||||
|
||||
// build the record payload
|
||||
RecordPayload payload(_uri, _uri_size);
|
||||
|
||||
return message_builder.append_record(type, payload, is_last_record);
|
||||
}
|
||||
|
||||
size_t URI::get_record_size() const
|
||||
{
|
||||
if (!_uri) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return MessageBuilder::compute_record_size(
|
||||
Record(
|
||||
RecordType(
|
||||
RecordType::well_known_type,
|
||||
uri_record_type_value
|
||||
),
|
||||
RecordPayload(_uri, _uri_size),
|
||||
RecordID(),
|
||||
/* chunk */ false,
|
||||
/* last record */ false
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void URI::move_data(uint8_t *new_uri, size_t new_uri_size)
|
||||
{
|
||||
delete[] _uri;
|
||||
_uri = new_uri;
|
||||
_uri_size = new_uri_size;
|
||||
}
|
||||
|
||||
bool URIParser::do_parse(const Record &record, URI &uri)
|
||||
{
|
||||
if (record.type.tnf != RecordType::well_known_type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// the record type value should be equal to `U`
|
||||
if (record.type.value != make_const_Span(uri_record_type_value) ||
|
||||
record.payload.empty()
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// create the buffer
|
||||
size_t uri_record_size = record.payload.size();
|
||||
uint8_t *uri_record = new uint8_t[uri_record_size];
|
||||
memcpy(uri_record, record.payload.data(), uri_record_size);
|
||||
|
||||
uri.move_data(uri_record, uri_record_size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace common
|
||||
} // namespace ndef
|
||||
} // namespace nfc
|
||||
} // namespace mbed
|
||||
|
||||
|
||||
39
connectivity/nfc/source/ndef/common/util.cpp
Normal file
39
connectivity/nfc/source/ndef/common/util.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/* mbed Microcontroller Library
|
||||
* Copyright (c) 2018 ARM Limited
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "nfc/ndef/common/util.h"
|
||||
|
||||
namespace mbed {
|
||||
namespace nfc {
|
||||
namespace ndef {
|
||||
namespace common {
|
||||
|
||||
Span<const uint8_t> span_from_cstr(const char *cstr)
|
||||
{
|
||||
return Span<const uint8_t>((const uint8_t *)cstr, strlen(cstr));
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
} // namespace common
|
||||
} // namespace ndef
|
||||
} // namespace nfc
|
||||
} // namespace mbed
|
||||
|
||||
Reference in New Issue
Block a user