Qubit 2020 / presensfirmwareupdate

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers wifi.h Source File

wifi.h

00001 #ifndef WIFI_H
00002 #define WIFI_H
00003 
00004 #include <stddef.h>
00005 #include "cisme.h"
00006 
00007 #ifdef USE_WIFI
00008 #define WIFI_MESSAGE_MAX_LENGTH 256
00009 
00010 /*
00011  * Current wifi board will send TCP message in the following 3 cases:
00012  * 1) When it receives some specific symbol specified during
00013  *    reconfiguration. This case is disabled currently.
00014  * 2) When the flush buffer if full. Currently during
00015  *    reconfiguration we set flush buffer to max value
00016  *    ~= 1500 bytes.
00017  * 3) When it doesn't receive any new data during some
00018  *    timer. During reconfiguration timer length is set
00019  *    to this value. Default value is 0.005 seconds. With
00020  *    such timer length sometimes we observing situation when
00021  *    one message is split on 2-3 TCP messages. With this timer
00022  *    length this is not observed. But sometimes we can concatenate
00023  *    some messages into one TCP message. To avoid this the program
00024  *    should wait this timer value (probably twice) before sending of
00025  *    the next message.
00026 */
00027 #define WIFI_COMM_TIME    100
00028 
00029 /**
00030  * Initialize Wi-Fi.
00031  */
00032 void wifiInit(void);
00033 
00034 /**
00035  * Get received message.
00036  *
00037  * @param msg Received message.
00038  * @return message length.
00039  */
00040 size_t wifiGetMessage(uint8_t** msg);
00041 
00042 /**
00043  * Send message.
00044  *
00045  * @param msg Message to be sent.
00046  * @param len Message length.
00047  */
00048 void wifiSendMessage(const uint8_t* msg, size_t len);
00049 
00050 /**
00051  * Get state of TCP connection.
00052  *
00053  * @return true if there is active TCP connection, false otherwise.
00054  */
00055 bool wifiTcpConnectionActive(void);
00056 
00057 #else // USE_WIFI
00058 
00059 static inline void wifiInit(void)
00060 {
00061 }
00062 
00063 static inline size_t wifiGetMessage(uint8_t** msg)
00064 {
00065     return 0;
00066 }
00067 
00068 static inline void wifiSendMessage(const uint8_t* msg, size_t len)
00069 {
00070 }
00071 
00072 static inline bool wifiTcpConnectionActive(void)
00073 {
00074     return false;
00075 }
00076 
00077 #endif // USE_WIFI
00078 
00079 #endif // WIFI_H