nina-fw/main/CommandHandler.h

56 lines
1.7 KiB
C++

/*
This file is part of the Arduino NINA firmware.
Copyright (c) 2018 Arduino SA. All rights reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef COMMAND_HANDLER_H
#define COMMAND_HANDLER_H
#include <stdint.h>
// include for esp_netif_recv_ret_t
#include "lwip/esp_netif_net_stack.h"
typedef esp_netif_recv_ret_t (*lwip_input_fn_t)(void *input_netif_handle, void *buffer, size_t len, void *eb);
class CommandHandlerClass {
public:
CommandHandlerClass();
void begin();
int handle(const uint8_t command[], uint8_t response[]);
static void onWiFiReceive();
static void onWiFiDisconnect(arduino_event_t*);
lwip_input_fn_t staNetifInput_orig = NULL;
lwip_input_fn_t apNetifInput_orig = NULL;
private:
static void gpio0Updater(void*);
static int ping(/*IPAddress*/uint32_t host, uint8_t ttl);
void updateGpio0Pin();
void handleWiFiReceive();
void handleWiFiDisconnect();
private:
SemaphoreHandle_t _updateGpio0PinSemaphore;
};
extern CommandHandlerClass CommandHandler;
extern "C" int downloadAndSaveFile(char * url, FILE * f, const char * cert_pem);
#endif