this is using the mbed os version 5-13-1

Dependencies:   mbed-http

source/common_types.h

Committer:
ocomeni
Date:
2019-04-01
Revision:
89:45f6db09a76d
Parent:
87:99b37d26ff2a
Child:
90:ed0267eca7b5

File content as of revision 89:45f6db09a76d:

#ifndef __COMMON_TYPES_H__
#define __COMMON_TYPES_H__
#include <mbed.h>
#include <string>
#include "ble/BLE.h"
#include "SecurityManager.h"
#include "http_request.h"
#include "common_config.h"
#define BLE_MAX_DEVICE_NAME_LEN 10
#define MAX_SSID_LEN 32
#define MAX_PASSKEY_LEN 32
#define EDM_START_BYTE       0xAA
#define EDM_STOP_BYTE        0x55
#define EDM_HDR_LEN          5
#define MAX_EDM_PAYLOAD_LEN  (4096-1)
#define MIN_EDM_PAYLOAD_LEN (2)
#define MAX_HTTP_HEADER_LINES
#define MAX_URL_LEN          100

/** ble configuration structure
*/
typedef struct ble_config {
    char      deviceName[BLE_MAX_DEVICE_NAME_LEN]; /* BLE Device Name */
    uint16_t  advInterval; /* advertising interval in msecs */
    uint16_t  advTimeout;  /* advertising timeout in secs */
    //Passkey_t pairingKey;  /* pairing Key */
    uint8_t   pairingKey[6];  /* pairing Key */
} ble_config_t;

/** ble configuration structure
*/
typedef struct wifi_config {
    char             ssid[MAX_SSID_LEN]; /* WiFi SSID */
    char             pass[MAX_PASSKEY_LEN]; /* WiFi Passkey */
    nsapi_security_t security;  /* WiFi security */
} wifi_config_t;

/** ble configuration structure
*/
typedef struct app_config {
    wifi_config_t wifi_config; /* wifi configuration */
    ble_config_t ble_config;   /* ble configuration */
} app_config_t;


typedef enum wifi_cmd
{
  WIFI_CMD_NONE,
  WIFI_CMD_CONFIG,
  WIFI_CMD_INTERNET_CONFIG,
  WIFI_CMD_SCAN,
  WIFI_CMD_DETAILED_SCAN,
  WIFI_CMD_CONNECT,
  WIFI_CMD_DISCONNECT,
  WIFI_CMD_SEND_HTTPS_REQ,
  WIFI_CMD_SEND_HTTP_REQ
}wifi_cmd_t;

typedef enum at_cmd_resp
{
  AT_RESP_NONE,
  AT_SCAN_RESP,
  AT_DETAILED_SCAN_RESP,
  AT_CONNECT_RESP,
  AT_DISCONNECT_RESP,
  WIFI_RECONNECT_INFO,
  WIFI_DISCONNECT_INFO,
  AT_CONFIG_RESP,
  AT_INTERNET_CONFIG_RESP,
  AT_HTTPS_RESP,
  AT_HTTPS_RESP_DOWNLOAD,
  AT_HTTP_RESP,
  AT_HTTP_RESP_DOWNLOAD
}at_cmd_resp_t;


typedef enum at_data_mode
{
  AT_CMD_DATA_MODE,
  AT_STD_DATA_MODE,
  AT_EXT_DATA_MODE
}at_data_mode_t;

typedef enum edm_payload_id
{
  CONNECT_EVENT    = 0x0011,
  DISCONNECT_EVENT = 0x0021,
  DATA_EVENT       = 0x0031,
  DATA_COMMAND     = 0x0036,
  AT_REQUEST       = 0x0044,
  AT_CONFIRMATION  = 0x0045,
  AT_EVENT         = 0x0041
}edm_payload_id_t;

typedef enum conn_scheme
{
  INVALID_SCHEME,
  ALWAYS_CONNECTED,
  EXTERNAL_CONNECT
}conn_scheme_t;


typedef struct {
    wifi_cmd_t    wifi_cmd;   /* wifi command */
} wifi_cmd_message_t;

typedef struct {
    at_cmd_resp_t    at_resp;   /* AT response */
} at_resp_message_t;

typedef struct {
    wifi_cmd_t    wifi_cmd;              /* wifi data command */
    int           dataLen;              /* size of data in buffer */
    uint8_t       buffer[TX_BUFFER_LEN]; /* buffer length     */
} wifi_data_msg_t;

typedef struct {
    at_cmd_resp_t at_resp;              /* AT response */
    int           dataLen;              /* size of data in buffer */
    uint8_t       buffer[TX_BUFFER_LEN]; /* buffer length     */
} at_data_msg_t;

typedef struct {
    http_method   method;       /* POST/GET etc... */
    std::string   request_URI;  /* request URI/path */
    std::string   http_version; /* http verstion HTTP/1.1 */
    std::string   hostName;     /* host name */
    std::string   AcceptVal;    /* types accepted */
    std::string   contentType;  /* content type */
    std::string   contentLen;   /* content length as string   */
    uint8_t       body[900];    /* body     */
} http_request_t;

typedef struct {
    uint8_t       startByte;   /* start Byte 0xAA */
    uint16_t      payloadLen;  /* payload Length */
    uint16_t      payloadID;   /* payload identifier     */
} edm_header_t;

typedef struct {
    string        contentType;  /* content type */
    int           bodyLen;      /* body length     */
    uint8_t       body[900];    /* body     */
} http_response_t;

typedef struct {
    uint8_t       peer_id          ;  /* peer id */
    conn_scheme_t connectionScheme;   /* connection scheme     */
    //string     *  url;          /* body     */
    char        url[MAX_URL_LEN];          /* body     */
} internet_config_t;

#endif  // __COMMON_TYPES_H__