Mistake on this page? Email us
m2mblockmessage.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 ARM Limited. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  * Licensed under the Apache License, Version 2.0 (the License); you may
5  * not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #ifndef M2MBLOCKMESSAGE_H
17 #define M2MBLOCKMESSAGE_H
18 
19 #include "ns_types.h"
20 #include "sn_coap_header.h"
21 
27 
28 public:
29 
34  typedef enum {
35  ErrorNone = 0,
36  EntityTooLarge
37  }Error;
38 
43 
47  virtual ~M2MBlockMessage();
48 
53  void set_message_info(sn_coap_hdr_s *coap_header);
54 
61  void set_payload(const uint8_t *payload, const uint16_t payload_len, const uint16_t offset);
62 
66  void clear_values();
67 
73  bool is_block_message() const;
74 
79  uint16_t block_number() const;
80 
85  uint32_t total_message_size() const;
86 
91  bool is_last_block() const;
92 
97  uint8_t* block_data() const;
98 
103  uint32_t block_data_len() const;
104 
109  Error error_code() const;
110 
111 private:
112  uint8_t *_block_data_ptr;
113  uint32_t _total_message_size;
114  uint16_t _block_data_len;
115  uint16_t _block_number;
116  Error _error_code;
117  bool _is_last_block;
118  bool _is_block_message;
119 };
120 
121 #endif // M2MBLOCKMESSAGE_H
uint32_t total_message_size() const
Returns the total size of the message.
void set_payload(const uint8_t *payload, const uint16_t payload_len, const uint16_t offset)
Store the payload data from a CoAP message.
bool is_block_message() const
Check if the message is a block message.
virtual ~M2MBlockMessage()
Error error_code() const
Returns an error code.
Definition: m2mblockmessage.h:26
void clear_values()
Clear values.
uint16_t block_number() const
Returns the number of an incoming block.
void set_message_info(sn_coap_hdr_s *coap_header)
Store the data from a CoAP message.
uint8_t * block_data() const
Returns the payload of the message.
bool is_last_block() const
Check if last block.
uint32_t block_data_len() const
Returns the length of the payload.
Error
An enum defining different kinds of errors that can occur during the block-wise operation.
Definition: m2mblockmessage.h:34