Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Payload.h
00001 /************************************************************************************** 00002 * Copyright (c) 2016, Tomoaki Yamaguchi 00003 * 00004 * All rights reserved. This program and the accompanying materials 00005 * are made available under the terms of the Eclipse Public License v1.0 00006 * and Eclipse Distribution License v1.0 which accompany this distribution. 00007 * 00008 * The Eclipse Public License is available at 00009 * http://www.eclipse.org/legal/epl-v10.html 00010 * and the Eclipse Distribution License is available at 00011 * http://www.eclipse.org/org/documents/edl-v10.php. 00012 * 00013 * Contributors: 00014 * Tomoaki Yamaguchi - initial API and implementation and/or initial documentation 00015 **************************************************************************************/ 00016 00017 #ifndef PAYLOAD_H_ 00018 #define PAYLOAD_H_ 00019 00020 #include "LMqttsnClientApp.h" 00021 00022 #define MSGPACK_FALSE 0xc2 00023 #define MSGPACK_TRUE 0xc3 00024 #define MSGPACK_POSINT 0x80 00025 #define MSGPACK_NEGINT 0xe0 00026 #define MSGPACK_UINT8 0xcc 00027 #define MSGPACK_UINT16 0xcd 00028 #define MSGPACK_UINT32 0xce 00029 #define MSGPACK_INT8 0xd0 00030 #define MSGPACK_INT16 0xd1 00031 #define MSGPACK_INT32 0xd2 00032 #define MSGPACK_FLOAT32 0xca 00033 #define MSGPACK_FIXSTR 0xa0 00034 #define MSGPACK_STR8 0xd9 00035 #define MSGPACK_STR16 0xda 00036 #define MSGPACK_ARRAY15 0x90 00037 #define MSGPACK_ARRAY16 0xdc 00038 #define MSGPACK_MAX_ELEMENTS 50 // Less than 256 00039 00040 namespace linuxAsyncClient { 00041 /*===================================== 00042 Class Payload 00043 =====================================*/ 00044 class Payload{ 00045 public: 00046 Payload(); 00047 Payload(uint16_t len); 00048 ~Payload(); 00049 00050 /*--------------------------------------------- 00051 getLen() and getRowData() are 00052 minimum required functions of Payload class. 00053 ----------------------------------------------*/ 00054 uint16_t getLen(); // get data length 00055 uint8_t* getRowData(); // get data pointer 00056 00057 /*--- Functions for MessagePack ---*/ 00058 void init(void); 00059 int8_t set_bool(bool val); 00060 int8_t set_uint32(uint32_t val); 00061 int8_t set_int32(int32_t val); 00062 int8_t set_float(float val); 00063 int8_t set_str(char* val); 00064 int8_t set_str(const char* val); 00065 int8_t set_array(uint8_t val); 00066 00067 bool get_bool(uint8_t index); 00068 uint8_t getArray(uint8_t index); 00069 uint32_t get_uint32(uint8_t index); 00070 int32_t get_int32(uint8_t index); 00071 float get_float(uint8_t index); 00072 const char* get_str(uint8_t index, uint16_t* len); 00073 00074 void setRowData(uint8_t* payload, uint16_t payloadLen); 00075 uint16_t getAvailableLength(); 00076 private: 00077 uint8_t* getBufferPos(uint8_t index); 00078 uint8_t* _buff; 00079 uint16_t _len; 00080 uint8_t _elmCnt; 00081 uint8_t* _pos; 00082 uint8_t _memDlt; 00083 }; 00084 00085 } /* linuxAsyncClient */ 00086 00087 #endif /* PAYLOAD_H_ */
Generated on Wed Jul 13 2022 10:46:03 by
1.7.2