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.
Dependents: oldheating gps motorhome heating
Diff: web-connection.c
- Revision:
- 130:9a5b8fe308f1
- Parent:
- 129:6d9bffc72676
- Child:
- 131:a9793a9721c7
--- a/web-connection.c Sun Sep 01 18:12:48 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-#include <stdlib.h>
-
-#include "web-connection.h"
-#include "mstimer.h"
-
-#define MAX_CONNECTIONS 10
-
-static struct WebConnection connections[MAX_CONNECTIONS];
-
-static void zeroConnection(struct WebConnection* p)
-{
- p->id = 0;
- p->lastUsed = 0;
- p->toDo = 0;
- p->postComplete = false;
- p->delayUntil = 0;
-}
-
-struct WebConnection* WebConnectionNew(int connectionId) //Never fails so never returns NULL
-{
- struct WebConnection* p;
-
- //Look for an existing connection
- for (p = connections; p < connections + MAX_CONNECTIONS; p++)
- {
- if (p->id == connectionId) goto end;
- }
-
- //look for an empty connection
- {
- struct WebConnection* pOldest = 0;
- uint32_t ageOldest = 0;
- for (p = connections; p < connections + MAX_CONNECTIONS; p++)
- {
- if (!p->id) goto end;
-
- //Otherwise record the oldest and keep going
- uint32_t age = MsTimerCount - p->lastUsed;
- if (age >= ageOldest)
- {
- ageOldest = age;
- pOldest = p;
- }
- }
-
- //No empty ones found so use the oldest
- p = pOldest;
- }
-
-end:
- zeroConnection(p);
- p->id = connectionId;
- p->lastUsed = MsTimerCount;
- return p;
-}
-struct WebConnection* WebConnectionOrNull(int connectionId)
-{
- for (struct WebConnection* p = connections; p < connections + MAX_CONNECTIONS; p++)
- {
- if (p->id == connectionId)
- {
- p->lastUsed = MsTimerCount;
- return p;
- }
- }
- return NULL;
-}
-void WebConnectionReset(int connectionId)
-{
- for (struct WebConnection* p = connections; p < connections + MAX_CONNECTIONS; p++)
- {
- if (p->id == connectionId) zeroConnection(p);
- }
-}