Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .github/workflows/dangerjs.yml

This file was deleted.

87 changes: 0 additions & 87 deletions .github/workflows/docker.yml

This file was deleted.

213 changes: 213 additions & 0 deletions MutuallyHuman_Fork_Changes.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions components/esp_netif/include/lwip/esp_netif_net_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ err_t wlanif_init_nan(struct netif *netif);
*/
esp_netif_recv_ret_t wlanif_input(void *h, void *buffer, size_t len, void* l2_buff);

// Statistics
int wlanif_bytes_in(void);
int wlanif_bytes_out(void);

#ifdef __cplusplus
}
#endif
15 changes: 15 additions & 0 deletions components/esp_netif/lwip/netif/wlanif.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
#include "lwip/esp_pbuf_ref.h"
#include "esp_netif_types.h"

static int _bytes_in = 0;
static int _bytes_out = 0;

/**
* In this function, the hardware should be initialized.
* Called from wlanif_input().
Expand Down Expand Up @@ -88,6 +91,8 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
esp_err_t netif_ret = ESP_FAIL;
err_t ret = ERR_IF;

_bytes_out += q->len;

if(q->next == NULL) {
netif_ret = esp_netif_transmit_wrap(esp_netif, q->payload, q->len, q);

Expand Down Expand Up @@ -131,6 +136,14 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
return ret;
}

int wlanif_bytes_in(void) {
return _bytes_in;
}

int wlanif_bytes_out(void) {
return _bytes_out;
}

/**
* This function should be called when a packet is ready to be read
* from the interface. It uses the function low_level_input() that
Expand All @@ -156,6 +169,8 @@ esp_netif_recv_ret_t wlanif_input(void *h, void *buffer, size_t len, void* l2_bu
return ESP_NETIF_OPTIONAL_RETURN_CODE(ESP_FAIL);
}

_bytes_in += len;

#ifdef CONFIG_LWIP_L2_TO_L3_COPY
p = pbuf_alloc(PBUF_RAW, len, PBUF_RAM);
if (p == NULL) {
Expand Down
3 changes: 2 additions & 1 deletion components/freertos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ list(APPEND include_dirs

# Add FreeRTOS Kernel public include directories
list(APPEND include_dirs
"${kernel_impl}/include") # FreeRTOS headers via `#include "freertos/xxx.h"`
"${kernel_impl}/include" # FreeRTOS headers via `#include "freertos/xxx.h"`
"${kernel_impl}/include/freertos") # For WICED build system compatibility

# Add port public include directories
list(APPEND include_dirs
Expand Down
38 changes: 38 additions & 0 deletions components/json/json.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# Copyright 2020, Cypress Semiconductor Corporation or a subsidiary of
# Cypress Semiconductor Corporation. All Rights Reserved.
# This software, including source code, documentation and related
# materials ("Software"), is owned by Cypress Semiconductor Corporation
# or one of its subsidiaries ("Cypress") and is protected by and subject to
# worldwide patent protection (United States and foreign),
# United States copyright laws and international treaty provisions.
# Therefore, you may use this Software only as provided in the license
# agreement accompanying the software package from which you
# obtained this Software ("EULA").
# If no EULA applies, Cypress hereby grants you a personal, non-exclusive,
# non-transferable license to copy, modify, and compile the Software
# source code solely for use in connection with Cypress's
# integrated circuit products. Any reproduction, modification, translation,
# compilation, or representation of this Software except as specified
# above is prohibited without the express written permission of Cypress.
#
# Disclaimer: THIS SOFTWARE IS PROVIDED AS-IS, WITH NO WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, NONINFRINGEMENT, IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. Cypress
# reserves the right to make changes to the Software without notice. Cypress
# does not assume any liability arising out of the application or use of the
# Software or any product or circuit described in the Software. Cypress does
# not authorize its products for use in any products where a malfunction or
# failure of the Cypress product may reasonably be expected to result in
# significant property damage, injury or death ("High Risk Product"). By
# including Cypress's product in a High Risk Product, the manufacturer
# of such system or application assumes all risk of such use and in doing
# so agrees to indemnify Cypress against all liability.
#

NAME := Lib_Json

GLOBAL_INCLUDES := ./cJSON

$(NAME)_SOURCES := cJSON/cJSON.c \
cJSON/cJSON_Utils.c
9 changes: 9 additions & 0 deletions components/protocomm/include/security/protocomm_security.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#pragma once

#include <esp_err.h>
#include <stdbool.h>
#include "esp_event.h"

#ifdef __cplusplus
Expand Down Expand Up @@ -140,6 +141,14 @@ typedef struct protocomm_security {
uint32_t session_id,
const uint8_t *inbuf, ssize_t inlen,
uint8_t **outbuf, ssize_t *outlen);

/**
* Function which checks whether or not a secure connection has
* been established
*
* note: only relevant to security1
*/
bool (*secure_session_established)(protocomm_security_handle_t handle);
} protocomm_security_t;

#ifdef __cplusplus
Expand Down
22 changes: 22 additions & 0 deletions components/protocomm/include/transports/protocomm_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ typedef enum {
* (29 - (BLE device name length) - 2). */
#define MAX_BLE_MANUFACTURER_DATA_LEN 29

typedef enum {
// Peer is connected without any security (i.e., no PoP has been entered)
PROTOCOMM_BLE_PEER_CONNECTED,
// Peer disconnected
PROTOCOMM_BLE_PEER_DISCONNECTED,
// Peer is connected securely with a valid PoP
PROTOCOMM_BLE_PEER_CONNECTED_SECURE,
} ble_event;

/// type of function called when a peer device connects or disconnects
typedef void (*protocomm_ble_event_fn)(ble_event event);

#define BLE_ADDR_LEN 6
/**
* @brief This structure maps handler required by protocomm layer to
Expand Down Expand Up @@ -172,6 +184,16 @@ typedef struct protocomm_ble_config {
*/
esp_err_t protocomm_ble_start(protocomm_t *pc, const protocomm_ble_config_t *config);

esp_err_t protocomm_ble_set_manufacturer_data(uint8_t *data, uint8_t length);

/// Register a callback that is called when a BLE event occurs (peer connects or disconnects)
void protocomm_ble_register_ble_event_fn(protocomm_ble_event_fn fn);

/// Get the registered BLE event callback
///
/// @return protocomm_ble_event_fn callback, or NULL if no callback is registered.
protocomm_ble_event_fn protocomm_ble_get_ble_event_fn(void);

/**
* @brief Stop Bluetooth Low Energy based transport layer for provisioning
*
Expand Down
10 changes: 9 additions & 1 deletion components/protocomm/src/common/protocomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <sys/queue.h>

#include <protocomm.h>
#include <protocomm_ble.h>
#include <protocomm_security.h>

#include "protocomm_priv.h"
Expand Down Expand Up @@ -265,11 +266,18 @@ static int protocomm_common_security_handler(uint32_t session_id,
protocomm_t *pc = (protocomm_t *) priv_data;

if (pc->sec && pc->sec->security_req_handler) {
return pc->sec->security_req_handler(pc->sec_inst,
esp_err_t ret = pc->sec->security_req_handler(pc->sec_inst,
pc->sec_params, session_id,
inbuf, inlen,
outbuf, outlen,
priv_data);
if (ESP_OK == ret && NULL != pc->sec->secure_session_established) {
protocomm_ble_event_fn fn = protocomm_ble_get_ble_event_fn();

if (NULL != fn && pc->sec->secure_session_established(pc->sec_inst)) {
fn(PROTOCOMM_BLE_PEER_CONNECTED_SECURE);
}
}
}

return ESP_OK;
Expand Down
12 changes: 11 additions & 1 deletion components/protocomm/src/security/security1.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static esp_err_t handle_session_command1(session_t *cur_session,
ESP_LOGE(TAG, "Failed to post secure session setup success event");
}

ESP_LOGD(TAG, "Secure session established successfully");
ESP_LOGI(TAG, "Secure session established successfully");
return ESP_OK;
}

Expand Down Expand Up @@ -602,6 +602,15 @@ static esp_err_t sec1_req_handler(protocomm_security_handle_t handle,
return ESP_OK;
}

static bool sec1_secure_session_established(protocomm_security_handle_t handle) {
session_t *cur_session = (session_t *) handle;
if (NULL == cur_session) {
return false;
}

return cur_session->state == SESSION_STATE_DONE;
}

const protocomm_security_t protocomm_security1 = {
.ver = 1,
.init = sec1_init,
Expand All @@ -611,4 +620,5 @@ const protocomm_security_t protocomm_security1 = {
.security_req_handler = sec1_req_handler,
.encrypt = sec1_decrypt, /* Encrypt == decrypt for AES-CTR */
.decrypt = sec1_decrypt,
.secure_session_established = sec1_secure_session_established,
};
Loading