This is a SLIP interface for the STM32F446RE Nucleo Board. It is designed to work specifically with the esp-link software for the ESP8266. The program is an example of a rest command.
STMClientResponse.h
00001 #ifndef _STM_CLIENT_RESPONSE_H_ 00002 #define _STM_CLIENT_RESPONSE_H_ 00003 00004 #if _MSC_VER 00005 #define PACKED 00006 #else 00007 #define PACKED __attribute__ ((__packed__)) 00008 #endif 00009 00010 #include <mbed.h> 00011 #include <string> 00012 00013 typedef struct PACKED { 00014 uint16_t cmd; // command to execute 00015 uint16_t argc; // number of arguments 00016 uint32_t value; // callback to invoke, NULL if none; or response value 00017 uint8_t args[0]; 00018 } STMClientPacket; 00019 00020 class STMClientResponse { 00021 public: 00022 // Create a response from a packet, this is done internally in STMClient 00023 STMClientResponse(STMClientPacket* packet); 00024 STMClientResponse(void *packet); 00025 00026 // Accessors to the response fields 00027 uint16_t argc() { return _cmd->argc; } 00028 uint16_t cmd() { return _cmd->cmd; } 00029 uint32_t value() { return _cmd->value; } 00030 00031 // Return the length of the next argument 00032 uint16_t argLen() { return *(uint16_t*)_arg_ptr; } 00033 // Pop one argument from the response, returns the actual length. Returns -1 if there is 00034 // no arg left. 00035 int16_t popArg(void* data, uint16_t maxLen); 00036 // Pop one argument as a poiner from the response, returns the actual length. 00037 int16_t popArgPtr(void **data); 00038 // Pop one argument into a string buffer and append a null character. The buffer needs to 00039 // be large enough (argLen()+1) 00040 void popChar(char* buffer); 00041 // Pop one argument into a String buffer 00042 string popString(); 00043 // Pop one argument into a String buffer 00044 void popString(string* data); 00045 00046 private: 00047 uint16_t _arg_num; 00048 uint8_t* _arg_ptr; 00049 STMClientPacket* _cmd; 00050 }; 00051 00052 #endif // _STM_CLIENT_RESPONSE_H_
Generated on Thu Jul 14 2022 21:27:07 by 1.7.2