Fixed custom headers and Basic authorization, added support for redirection, functional file download interface can be used for SW updates and more.

Dependents:   Sample_HTTPClient Sample_HTTPClient LWM2M_NanoService_Ethernet LWM2M_NanoService_Ethernet ... more

Fork of HTTPClient by Vincent Wochnik

More recent changes - added iCal processing.

Derivative of a derivative, however this one works when it comes to supplying Basic authorization to access a protected resource. Some additional changes to the debug interface to clean it up for consistency with many other components I have.

Committer:
WiredHome
Date:
Tue Mar 14 02:59:32 2017 +0000
Revision:
40:bcb19f8dbba3
Parent:
39:21fc7a4b6927
Revisions to clean up the iCal interface.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
WiredHome 39:21fc7a4b6927 1 #ifndef HTTPICAL_H
WiredHome 39:21fc7a4b6927 2 #define HTTPICAL_H
WiredHome 39:21fc7a4b6927 3 #include <mbed.h>
WiredHome 39:21fc7a4b6927 4 #include "../IHTTPData.h"
WiredHome 39:21fc7a4b6927 5
WiredHome 39:21fc7a4b6927 6
WiredHome 39:21fc7a4b6927 7 /// An iCal handling mechanism - downloads and parses calendar events
WiredHome 39:21fc7a4b6927 8 class HTTPiCal : public IHTTPDataIn {
WiredHome 39:21fc7a4b6927 9
WiredHome 39:21fc7a4b6927 10 public:
WiredHome 39:21fc7a4b6927 11 #define SUMMARY_CHARS 100
WiredHome 39:21fc7a4b6927 12 #define LOCATION_CHARS 100
WiredHome 39:21fc7a4b6927 13 #define CATEGORY_CHARS 20
WiredHome 39:21fc7a4b6927 14 #define LINEBUFLEN 200
WiredHome 39:21fc7a4b6927 15
WiredHome 39:21fc7a4b6927 16 /// The repeat attribute for an event
WiredHome 39:21fc7a4b6927 17 typedef enum {
WiredHome 39:21fc7a4b6927 18 rptfNone, ///< no repeat for this event
WiredHome 39:21fc7a4b6927 19 rptfDaily, ///< daily repeat
WiredHome 39:21fc7a4b6927 20 rptfWeekly, ///< weekly repeat
WiredHome 39:21fc7a4b6927 21 rptfMonthly, ///< monthly repeat
WiredHome 39:21fc7a4b6927 22 rptfYearly ///< yearly repeat
WiredHome 39:21fc7a4b6927 23 } RepeatFreq_t;
WiredHome 39:21fc7a4b6927 24
WiredHome 39:21fc7a4b6927 25 typedef int32_t tz_sec_t;
WiredHome 39:21fc7a4b6927 26 typedef int16_t tz_min_t;
WiredHome 39:21fc7a4b6927 27
WiredHome 39:21fc7a4b6927 28 /// A single event consists of quite a number of attributes.
WiredHome 39:21fc7a4b6927 29 typedef struct {
WiredHome 39:21fc7a4b6927 30 time_t Start;
WiredHome 39:21fc7a4b6927 31 time_t End;
WiredHome 39:21fc7a4b6927 32 time_t Until;
WiredHome 39:21fc7a4b6927 33 uint16_t Count;
WiredHome 39:21fc7a4b6927 34 uint16_t Interval;
WiredHome 39:21fc7a4b6927 35 RepeatFreq_t RepeatFreq;
WiredHome 39:21fc7a4b6927 36 uint8_t RepeatDays; // bit mapped (bit 0 = sunday, bit 1=monday, ...)
WiredHome 39:21fc7a4b6927 37 uint16_t RepeatMonths; // bit mapped (bit 0 = jan, 1=feb, ...)
WiredHome 39:21fc7a4b6927 38 uint32_t RepeatMonthDay; // bit mapped (bit 1 = 1st, 2=2nd, ...)
WiredHome 39:21fc7a4b6927 39 uint32_t RepeatMonthDayRev; // reverse -1 = last day = bit 1, -2=bit 2, ...
WiredHome 39:21fc7a4b6927 40 char Summary[SUMMARY_CHARS];
WiredHome 39:21fc7a4b6927 41 char Location[LOCATION_CHARS];
WiredHome 39:21fc7a4b6927 42 char Category[CATEGORY_CHARS]; // "Green", ...
WiredHome 39:21fc7a4b6927 43 int Priority; // 1 == High, 5 == Normal, 9 == Low
WiredHome 39:21fc7a4b6927 44 } Event_T;
WiredHome 39:21fc7a4b6927 45
WiredHome 39:21fc7a4b6927 46
WiredHome 39:21fc7a4b6927 47 /// Instantiate HTTPiCal
WiredHome 39:21fc7a4b6927 48 ///
WiredHome 39:21fc7a4b6927 49 /// @code
WiredHome 39:21fc7a4b6927 50 /// HTTPClient http;
WiredHome 39:21fc7a4b6927 51 /// HTTPiCal iCal(10); // define a limit of 10 events to be held
WiredHome 39:21fc7a4b6927 52 ///
WiredHome 39:21fc7a4b6927 53 /// http.basicAuth(calInfo.user, calInfo.pass);
WiredHome 39:21fc7a4b6927 54 ///
WiredHome 39:21fc7a4b6927 55 /// time_t now = t.timelocal(); // Set a 4-hour window from now
WiredHome 39:21fc7a4b6927 56 /// time_t nxt = now + 4 * 3600;
WiredHome 39:21fc7a4b6927 57 /// ical.SetTimeWindow(now, nxt);
WiredHome 39:21fc7a4b6927 58 /// HTTPErrorCode = http.get(calInfo.url, &iCal);
WiredHome 39:21fc7a4b6927 59 /// if (HTTPErrorCode == HTTP_OK) {
WiredHome 39:21fc7a4b6927 60 /// // calendar successfully downloaded
WiredHome 39:21fc7a4b6927 61 /// for (int i=0; i<iCal.GetEventCount(); i++) {
WiredHome 39:21fc7a4b6927 62 /// HTTPiCal::Event_T event;
WiredHome 39:21fc7a4b6927 63 /// if (ical.GetEvent(i, &event)) {
WiredHome 39:21fc7a4b6927 64 /// printf("Event %d\r\n", i);
WiredHome 39:21fc7a4b6927 65 /// printf("Summary : %s\r\n", event.Summary);
WiredHome 39:21fc7a4b6927 66 /// printf("Location: %s\r\n", event.Location);
WiredHome 39:21fc7a4b6927 67 /// printf("Category: %s\r\n", event.Category);
WiredHome 39:21fc7a4b6927 68 /// }
WiredHome 39:21fc7a4b6927 69 /// }
WiredHome 39:21fc7a4b6927 70 /// }
WiredHome 39:21fc7a4b6927 71 /// @endcode
WiredHome 39:21fc7a4b6927 72 ///
WiredHome 39:21fc7a4b6927 73 /// @param count is the number of Event_T entries to reserve space for.
WiredHome 39:21fc7a4b6927 74 ///
WiredHome 39:21fc7a4b6927 75 HTTPiCal(int count);
WiredHome 39:21fc7a4b6927 76
WiredHome 39:21fc7a4b6927 77 /// Destructor to free memory
WiredHome 39:21fc7a4b6927 78 ~HTTPiCal();
WiredHome 39:21fc7a4b6927 79
WiredHome 39:21fc7a4b6927 80 /// Set the time window of interest, for which to retain events.
WiredHome 39:21fc7a4b6927 81 ///
WiredHome 39:21fc7a4b6927 82 /// This sets the time window of interest. Any event, whether directly
WiredHome 39:21fc7a4b6927 83 /// scheduled in this window, or indirectly via repeat attributes, will
WiredHome 39:21fc7a4b6927 84 /// be retained in the list of available events. Any event not in this
WiredHome 39:21fc7a4b6927 85 /// window will be ignored.
WiredHome 39:21fc7a4b6927 86 ///
WiredHome 39:21fc7a4b6927 87 /// @param StartTime is the optional time value for the beginning of
WiredHome 39:21fc7a4b6927 88 /// interest. If gridStartTime is zero, no filtering is performed.
WiredHome 39:21fc7a4b6927 89 /// @param EndTime is the optional time value ending the period of interest.
WiredHome 39:21fc7a4b6927 90 ///
WiredHome 39:21fc7a4b6927 91 void SetTimeWindow(time_t StartTime = 0, time_t EndTime = 0);
WiredHome 39:21fc7a4b6927 92
WiredHome 39:21fc7a4b6927 93 /// Get the count of Events currently available.
WiredHome 39:21fc7a4b6927 94 ///
WiredHome 39:21fc7a4b6927 95 /// @returns the count of events.
WiredHome 39:21fc7a4b6927 96 ///
WiredHome 39:21fc7a4b6927 97 int GetEventCount(void) { return EventCount; }
WiredHome 39:21fc7a4b6927 98
WiredHome 39:21fc7a4b6927 99 /// Get a copy of the specified event.
WiredHome 39:21fc7a4b6927 100 ///
WiredHome 39:21fc7a4b6927 101 /// @param i is the event number, ranging from 0 to GetEventCount()
WiredHome 39:21fc7a4b6927 102 /// @param event is a pointer to where the event will be copied.
WiredHome 39:21fc7a4b6927 103 /// @returns true if the event was available and copied.
WiredHome 39:21fc7a4b6927 104 ///
WiredHome 39:21fc7a4b6927 105 bool GetEvent(unsigned int i, Event_T * event);
WiredHome 40:bcb19f8dbba3 106
WiredHome 40:bcb19f8dbba3 107
WiredHome 40:bcb19f8dbba3 108 /// Compute the intersection of two time ranges, and evaluate the recurringing events.
WiredHome 40:bcb19f8dbba3 109 ///
WiredHome 40:bcb19f8dbba3 110 /// This compares a pair of time ranges, each by a start and end time. If they overlap
WiredHome 40:bcb19f8dbba3 111 /// it then computes the intersection of those two ranges. Additionally, for a
WiredHome 40:bcb19f8dbba3 112 /// specified Event, it will evaluate the recurring events that may also fall into
WiredHome 40:bcb19f8dbba3 113 /// the target time range.
WiredHome 40:bcb19f8dbba3 114 ///
WiredHome 40:bcb19f8dbba3 115 /// @note This is usually the only API you need, as this will first call
WiredHome 40:bcb19f8dbba3 116 /// the TimeIntersects function, and if that fails, then it will evaluate
WiredHome 40:bcb19f8dbba3 117 /// repeat information.
WiredHome 40:bcb19f8dbba3 118 ///
WiredHome 40:bcb19f8dbba3 119 /// @param[in,out] start1 is the starting time of range 1.
WiredHome 40:bcb19f8dbba3 120 /// @param[in,out] end1 is the ending time of range 1.
WiredHome 40:bcb19f8dbba3 121 /// @param[in] start2 is the starting time of range 2.
WiredHome 40:bcb19f8dbba3 122 /// @param[in] end2 is the ending time of range 2.
WiredHome 40:bcb19f8dbba3 123 /// @param[in] Event is a pointer to the event of interest that may have recurring series.
WiredHome 40:bcb19f8dbba3 124 /// @returns true if the ranges overlap, and then start1 and end1 are set to the
WiredHome 40:bcb19f8dbba3 125 /// intersection.
WiredHome 40:bcb19f8dbba3 126 ///
WiredHome 40:bcb19f8dbba3 127 bool RepeatIntersects(time_t * start1, time_t * end1, time_t * start2, time_t * end2, Event_T * Event = NULL);
WiredHome 39:21fc7a4b6927 128
WiredHome 40:bcb19f8dbba3 129
WiredHome 40:bcb19f8dbba3 130 /// Compute the intersection of two time ranges, and returns that intersection.
WiredHome 40:bcb19f8dbba3 131 ///
WiredHome 40:bcb19f8dbba3 132 /// This compares a pair of time ranges, each by a start and end time. If they overlap
WiredHome 40:bcb19f8dbba3 133 /// it then computes the intersection of those two ranges.
WiredHome 40:bcb19f8dbba3 134 ///
WiredHome 40:bcb19f8dbba3 135 /// @param[in,out] start1 is the starting time of range 1.
WiredHome 40:bcb19f8dbba3 136 /// @param[in,out] end1 is the ending time of range 1.
WiredHome 40:bcb19f8dbba3 137 /// @param[in] start2 is the starting time of range 2.
WiredHome 40:bcb19f8dbba3 138 /// @param[in] end2 is the ending time of range 2.
WiredHome 40:bcb19f8dbba3 139 /// @returns true if the ranges overlap, and then start1 and end1 are set to the
WiredHome 40:bcb19f8dbba3 140 /// intersection.
WiredHome 40:bcb19f8dbba3 141 ///
WiredHome 40:bcb19f8dbba3 142 bool TimeIntersects(time_t * start1, time_t * end1, time_t * start2, time_t * end2);
WiredHome 40:bcb19f8dbba3 143
WiredHome 40:bcb19f8dbba3 144
WiredHome 39:21fc7a4b6927 145 protected:
WiredHome 39:21fc7a4b6927 146
WiredHome 39:21fc7a4b6927 147 friend class HTTPClient;
WiredHome 39:21fc7a4b6927 148
WiredHome 39:21fc7a4b6927 149 /** Reset stream to its beginning
WiredHome 39:21fc7a4b6927 150 * Called by the HTTPClient on each new request
WiredHome 39:21fc7a4b6927 151 */
WiredHome 39:21fc7a4b6927 152 virtual void writeReset();
WiredHome 39:21fc7a4b6927 153
WiredHome 39:21fc7a4b6927 154 /** Write a piece of data transmitted by the server
WiredHome 39:21fc7a4b6927 155 * @param[in] buf Pointer to the buffer from which to copy the data
WiredHome 39:21fc7a4b6927 156 * @param[in] len Length of the buffer
WiredHome 39:21fc7a4b6927 157 * @returns number of bytes written.
WiredHome 39:21fc7a4b6927 158 */
WiredHome 39:21fc7a4b6927 159 virtual int write(const char* buf, size_t len);
WiredHome 39:21fc7a4b6927 160
WiredHome 39:21fc7a4b6927 161 /** Set MIME type
WiredHome 39:21fc7a4b6927 162 * @param[in] type Internet media type from Content-Type header
WiredHome 39:21fc7a4b6927 163 */
WiredHome 39:21fc7a4b6927 164 virtual void setDataType(const char* type);
WiredHome 39:21fc7a4b6927 165
WiredHome 39:21fc7a4b6927 166 /** Determine whether the data is chunked
WiredHome 39:21fc7a4b6927 167 * Recovered from Transfer-Encoding header
WiredHome 39:21fc7a4b6927 168 * @param[in] chunked indicates the transfer is chunked.
WiredHome 39:21fc7a4b6927 169 */
WiredHome 39:21fc7a4b6927 170 virtual void setIsChunked(bool chunked);
WiredHome 39:21fc7a4b6927 171
WiredHome 39:21fc7a4b6927 172 /** If the data is not chunked, set its size
WiredHome 39:21fc7a4b6927 173 * From Content-Length header
WiredHome 39:21fc7a4b6927 174 * @param[in] len defines the size of the non-chunked transfer.
WiredHome 39:21fc7a4b6927 175 */
WiredHome 39:21fc7a4b6927 176 virtual void setDataLen(size_t len);
WiredHome 39:21fc7a4b6927 177
WiredHome 39:21fc7a4b6927 178 private:
WiredHome 39:21fc7a4b6927 179 char lineBuf[LINEBUFLEN]; ///< workspace to copy [partial] lines into
WiredHome 39:21fc7a4b6927 180
WiredHome 39:21fc7a4b6927 181 Event_T * EventList; ///< Pointer to the array of events
WiredHome 39:21fc7a4b6927 182 int EventSpaceCount; ///< Maximum number of events that can be tracked
WiredHome 39:21fc7a4b6927 183 int EventCount; ///< Current Count of events
WiredHome 39:21fc7a4b6927 184
WiredHome 39:21fc7a4b6927 185 time_t gridStartTime; ///< defines the start of the time window of interest
WiredHome 39:21fc7a4b6927 186 time_t gridEndTime; ///< defines the end of the time winedow of interest
WiredHome 39:21fc7a4b6927 187
WiredHome 39:21fc7a4b6927 188 int32_t tzoTZIDSec;
WiredHome 39:21fc7a4b6927 189 bool tzAdjusted;
WiredHome 39:21fc7a4b6927 190
WiredHome 39:21fc7a4b6927 191 typedef enum {
WiredHome 39:21fc7a4b6927 192 idle,
WiredHome 39:21fc7a4b6927 193 inTimeZone,
WiredHome 39:21fc7a4b6927 194 inEvent
WiredHome 39:21fc7a4b6927 195 } seekstate_t;
WiredHome 39:21fc7a4b6927 196 seekstate_t seeking;
WiredHome 39:21fc7a4b6927 197
WiredHome 40:bcb19f8dbba3 198 #if !defined(min) && !defined(max)
WiredHome 39:21fc7a4b6927 199 #define min(a,b) (((a)<(b))?(a):(b))
WiredHome 39:21fc7a4b6927 200 #define max(a,b) (((a)>(b))?(a):(b))
WiredHome 40:bcb19f8dbba3 201 #endif
WiredHome 40:bcb19f8dbba3 202
WiredHome 39:21fc7a4b6927 203 /// Determine if a specific timestamp is in a leap year
WiredHome 39:21fc7a4b6927 204 ///
WiredHome 39:21fc7a4b6927 205 /// @param[in] t is the timestamp to evaluate
WiredHome 39:21fc7a4b6927 206 /// @returns true if the specified timestamp is within a leap year
WiredHome 39:21fc7a4b6927 207 ///
WiredHome 39:21fc7a4b6927 208 bool isLeapYear(time_t t);
WiredHome 39:21fc7a4b6927 209
WiredHome 39:21fc7a4b6927 210 /// Inspect the event to determine if its repeat attribute places it in the specified time window
WiredHome 39:21fc7a4b6927 211 ///
WiredHome 39:21fc7a4b6927 212 /// @param[in] start1 represents the start of the timerange of interest.
WiredHome 39:21fc7a4b6927 213 /// @param[in] end1 is the time range representing the end of the range of interest
WiredHome 39:21fc7a4b6927 214 /// @param[in] start2 is the time range of the event being tested
WiredHome 39:21fc7a4b6927 215 /// @param[in] end2 is the time range of the event being tested
WiredHome 39:21fc7a4b6927 216 /// @param[in] Event is a pointer to the event being tested and permits testing the repeat information.
WiredHome 39:21fc7a4b6927 217 /// @returns true if the event repeat pattern intersects with the display pattern
WiredHome 39:21fc7a4b6927 218 ///
WiredHome 39:21fc7a4b6927 219 bool RepeatMaskIntersects(time_t * start1, time_t * end1, time_t * start2, time_t * end2, Event_T * Event);
WiredHome 39:21fc7a4b6927 220
WiredHome 39:21fc7a4b6927 221 /// Convert 'n' characters in a string to an unsigned integer.
WiredHome 39:21fc7a4b6927 222 ///
WiredHome 39:21fc7a4b6927 223 /// @param[in] p is a pointer to the string.
WiredHome 39:21fc7a4b6927 224 /// @param[in] n is the number of characters to convert.
WiredHome 39:21fc7a4b6927 225 /// @returns an unsigned integer of the converted value.
WiredHome 39:21fc7a4b6927 226 ///
WiredHome 39:21fc7a4b6927 227 uint16_t AtoIxN(const char * p, int n);
WiredHome 39:21fc7a4b6927 228
WiredHome 39:21fc7a4b6927 229 /// Parse some information from the stream and extract event information.
WiredHome 39:21fc7a4b6927 230 ///
WiredHome 39:21fc7a4b6927 231 /// @param[in] Event is a pointer to the current event to populate.
WiredHome 39:21fc7a4b6927 232 /// @param[in] pStart is a pointer to the start of a text stream to evaluate.
WiredHome 39:21fc7a4b6927 233 /// @param[in] tzoSec is the time zone offset in seconds.
WiredHome 39:21fc7a4b6927 234 ///
WiredHome 39:21fc7a4b6927 235 void ParseEvent(Event_T * Event, const char * pStart, tz_sec_t tzoSec);
WiredHome 39:21fc7a4b6927 236
WiredHome 39:21fc7a4b6927 237
WiredHome 39:21fc7a4b6927 238 /// Prepare to start processing an iCal stream
WiredHome 39:21fc7a4b6927 239 ///
WiredHome 39:21fc7a4b6927 240 /// This initializes the data structures for parsing.
WiredHome 39:21fc7a4b6927 241 ///
WiredHome 39:21fc7a4b6927 242 /// @code
WiredHome 39:21fc7a4b6927 243 /// ParseICalStart();
WiredHome 39:21fc7a4b6927 244 /// while (receive(buf, ... ))
WiredHome 39:21fc7a4b6927 245 /// ParseICalStream(buf, ...);
WiredHome 39:21fc7a4b6927 246 /// count = ParseICalClose();
WiredHome 39:21fc7a4b6927 247 /// @endcode
WiredHome 39:21fc7a4b6927 248 ///
WiredHome 39:21fc7a4b6927 249 void ParseICalStart(void);
WiredHome 39:21fc7a4b6927 250
WiredHome 39:21fc7a4b6927 251
WiredHome 39:21fc7a4b6927 252 /// End processing an iCal stream and return the number of events
WiredHome 39:21fc7a4b6927 253 ///
WiredHome 39:21fc7a4b6927 254 /// @returns number of events in range
WiredHome 39:21fc7a4b6927 255 ///
WiredHome 39:21fc7a4b6927 256 int ParseICalClose(void);
WiredHome 39:21fc7a4b6927 257
WiredHome 39:21fc7a4b6927 258
WiredHome 39:21fc7a4b6927 259 /// Parse an iCal stream, and extract everything useful.
WiredHome 39:21fc7a4b6927 260 ///
WiredHome 39:21fc7a4b6927 261 /// This accepts a pointer to a [large] buffer, which is the contents
WiredHome 39:21fc7a4b6927 262 /// of an iCal stream. It walked through all of the available
WiredHome 39:21fc7a4b6927 263 /// information to extract the Event list.
WiredHome 39:21fc7a4b6927 264 ///
WiredHome 39:21fc7a4b6927 265 /// @param[in] pStart is a pointer to the start of the stream.
WiredHome 39:21fc7a4b6927 266 /// @param[in] gridStartTime is a time value representing the start of the time-window of interest.
WiredHome 39:21fc7a4b6927 267 /// @param[in] gridEndTime is a time value representing the end of the time-window of interest.
WiredHome 39:21fc7a4b6927 268 /// @param[in] tzoMin is the time-zone offset in minutes.
WiredHome 39:21fc7a4b6927 269 /// @param[in] showEvents when true causes it to print the events as parsed.
WiredHome 39:21fc7a4b6927 270 /// @returns number of events in range.
WiredHome 39:21fc7a4b6927 271 ///
WiredHome 39:21fc7a4b6927 272 int ParseICalStream(const char * pStart, time_t gridStartTime, time_t gridEndTime, tz_min_t tzoMin, bool showEvents = true);
WiredHome 39:21fc7a4b6927 273
WiredHome 39:21fc7a4b6927 274
WiredHome 39:21fc7a4b6927 275 /// Compute if the referenced event occurs within the specified time window.
WiredHome 39:21fc7a4b6927 276 ///
WiredHome 39:21fc7a4b6927 277 /// @param[in] startWindow is the starting timestamp.
WiredHome 39:21fc7a4b6927 278 /// @param[in] endWindow is the ending timestamp.
WiredHome 39:21fc7a4b6927 279 /// @param[in] Event is a pointer to the event, which can have repeat rules.
WiredHome 39:21fc7a4b6927 280 /// @returns true if the event laps into the current time window.
WiredHome 39:21fc7a4b6927 281 ///
WiredHome 40:bcb19f8dbba3 282 // bool EventIntersects(time_t startWindow, time_t endWindow, Event_T * Event);
WiredHome 40:bcb19f8dbba3 283
WiredHome 40:bcb19f8dbba3 284
WiredHome 39:21fc7a4b6927 285 // Private Functions - no real value external to the iCal public interface
WiredHome 39:21fc7a4b6927 286 // other than for test code.
WiredHome 39:21fc7a4b6927 287
WiredHome 39:21fc7a4b6927 288 /// Computes the next interval for iCal events that have recurrence.
WiredHome 39:21fc7a4b6927 289 ///
WiredHome 39:21fc7a4b6927 290 /// @param[in] baseT is the base time value which is a factor only in leap-year.
WiredHome 39:21fc7a4b6927 291 /// @param[in] repeatFreq is a value representing the frequency of recurrence -
WiredHome 39:21fc7a4b6927 292 /// 0=none, 1=daily, 2=weekly, 3=monthly, 4=yearly
WiredHome 39:21fc7a4b6927 293 /// @param[in] interval is the multiplier of that repeat frequency to the next
WiredHome 39:21fc7a4b6927 294 /// event.
WiredHome 39:21fc7a4b6927 295 /// @returns a time_t value which is the incremental interval, and would be added
WiredHome 39:21fc7a4b6927 296 /// to a reference time.
WiredHome 39:21fc7a4b6927 297 ///
WiredHome 39:21fc7a4b6927 298 time_t NextInterval(time_t baseT, int repeatFreq, int interval);
WiredHome 39:21fc7a4b6927 299
WiredHome 39:21fc7a4b6927 300
WiredHome 39:21fc7a4b6927 301 /// Format a ctime value as a string, without the trailing <cr>
WiredHome 39:21fc7a4b6927 302 ///
WiredHome 39:21fc7a4b6927 303 /// This uses the normal ctime function, which appends a <cr>, but
WiredHome 39:21fc7a4b6927 304 /// it then removes that trailing line ending character. Additionally,
WiredHome 39:21fc7a4b6927 305 /// this keeps a few local static buffers to return the time string in
WiredHome 39:21fc7a4b6927 306 /// which permits a printf (for example) to call this api a few times
WiredHome 39:21fc7a4b6927 307 /// and get the proper representation of each.
WiredHome 39:21fc7a4b6927 308 ///
WiredHome 39:21fc7a4b6927 309 /// @param[in] t is a time value;
WiredHome 39:21fc7a4b6927 310 /// @returns a pointer to a static buffer containing the converted time.
WiredHome 39:21fc7a4b6927 311 ///
WiredHome 39:21fc7a4b6927 312 char * FormatCTime(time_t t);
WiredHome 39:21fc7a4b6927 313
WiredHome 39:21fc7a4b6927 314 /// Sort the Events that have been extracted from the iCal results.
WiredHome 39:21fc7a4b6927 315 ///
WiredHome 39:21fc7a4b6927 316 void SortEvents();
WiredHome 39:21fc7a4b6927 317
WiredHome 39:21fc7a4b6927 318 /// Show the details for a specific Event, on the specified serial stream.
WiredHome 39:21fc7a4b6927 319 ///
WiredHome 39:21fc7a4b6927 320 /// Most useful during development, and perhaps no value after that.
WiredHome 39:21fc7a4b6927 321 ///
WiredHome 39:21fc7a4b6927 322 /// @param[in] Event is the event of interest.
WiredHome 39:21fc7a4b6927 323 ///
WiredHome 39:21fc7a4b6927 324 void ShowEventInfo(Event_T & Event);
WiredHome 39:21fc7a4b6927 325
WiredHome 39:21fc7a4b6927 326 /// Access the 2-letter abbreviation for the day of the week.
WiredHome 39:21fc7a4b6927 327 ///
WiredHome 39:21fc7a4b6927 328 /// @param[in] i is the day of the week, where 0 = sunday
WiredHome 39:21fc7a4b6927 329 /// @returns a pointer to the 2-letter abbreviation.
WiredHome 39:21fc7a4b6927 330 ///
WiredHome 39:21fc7a4b6927 331 const char * RepeatDayAbbrev(int i);
WiredHome 39:21fc7a4b6927 332
WiredHome 39:21fc7a4b6927 333 /// Parse a Datestamp string into a time value.
WiredHome 39:21fc7a4b6927 334 ///
WiredHome 39:21fc7a4b6927 335 /// Parses a string which can look like this: 20140505T200000
WiredHome 39:21fc7a4b6927 336 /// into a time_t value.
WiredHome 39:21fc7a4b6927 337 ///
WiredHome 39:21fc7a4b6927 338 /// @param[in] string is the string to parse.
WiredHome 39:21fc7a4b6927 339 /// @param[in] tzoSec is the time-zone offset in seconds.
WiredHome 39:21fc7a4b6927 340 /// @returns time_t value.
WiredHome 39:21fc7a4b6927 341 ///
WiredHome 39:21fc7a4b6927 342 time_t ParseDateStamp(const char * string, tz_sec_t tzoSec);
WiredHome 39:21fc7a4b6927 343
WiredHome 39:21fc7a4b6927 344 /// Parse a Time Zone ID value from the front-end of a Datestamp
WiredHome 39:21fc7a4b6927 345 ///
WiredHome 39:21fc7a4b6927 346 /// Parses a string which can look like one of these:
WiredHome 39:21fc7a4b6927 347 /// @li TZID="(GMT -06:00)":20140519T063000
WiredHome 39:21fc7a4b6927 348 /// @li TZID:(UTC-06:00) Central Time (US & Canada)
WiredHome 39:21fc7a4b6927 349 /// @li TZID:(GMT -06:00)
WiredHome 39:21fc7a4b6927 350 ///
WiredHome 39:21fc7a4b6927 351 /// @param[in] string to be parsed.
WiredHome 39:21fc7a4b6927 352 /// @returns time zone offset in seconds.
WiredHome 39:21fc7a4b6927 353 ///
WiredHome 39:21fc7a4b6927 354 tz_sec_t ParseTZID(const char * string);
WiredHome 39:21fc7a4b6927 355
WiredHome 39:21fc7a4b6927 356
WiredHome 39:21fc7a4b6927 357 bool m_chunked;
WiredHome 39:21fc7a4b6927 358 };
WiredHome 39:21fc7a4b6927 359 #endif // HTTPICAL_H