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
24 changes: 24 additions & 0 deletions Inc/communication/binary_download.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef _BINARY_DOWNLOAD_H
#define _BINARY_DOWNLOAD_H

#include "object_target.h"

// Downlaod States
#define NO_DOWNLOAD_DATA 0
#define DOWNLOAD_IN_PROGRESS 1
#define DOWNLOAD_ERROR 2
#define DOWNLOAD_COMPLETED 3

// Download Errors
#define NO_ERROR 0
#define UNKNOWN_ERROR -1
#define SOCKET_ERROR -2
#define CONNECTION_ERROR -3
#define REQUEST_ERROR -4
#define RECEIVE_ERROR -5
#define USB_ERROR -6
#define ERROR_PARSING_URL -7
#define HOST_UNKNOWN_ERROR -8

int startDownload(target_instance_t *targetP);
#endif
37 changes: 29 additions & 8 deletions Inc/communication/wakaama_client/objects/object_target.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,30 @@
#ifndef _TARGET_H
#define _TARGET_H

// Downlaod States
#define NO_DOWNLOAD_DATA 0
#define DOWNLOAD_IN_PROGRESS 1
#define DOWNLOAD_ERROR 2
#define DOWNLOAD_COMPLETED 3
#ifndef __OBJECT_TARGET_H
#define __OBJECT_TARGET_H


/*
* Multiple instance objects can use userdata to store data that will be shared between the different instances.
* The lwm2m_object_t object structure - which represent every object of the liblwm2m as seen in the single instance
* object - contain a chained list called instanceList with the object specific structure target_instance_t:
*/
typedef struct _target_instance_
{
/*
* The first two are mandatories and represent the pointer to the next instance and the ID of this one. The rest
* is the instance scope user data (uint8_t target in this case)
*/
struct _target_instance_ * next; // matches lwm2m_list_t::next
uint16_t shortID; // matches lwm2m_list_t::id

uint8_t flash_state;
uint32_t * target_type;
char * firmware_url;
uint8_t download_state;
int16_t download_error;
uint32_t firmware_version;
char * binary_filename;
uint8_t download_progress;
} target_instance_t;


#endif
115 changes: 115 additions & 0 deletions Inc/communication/yuarel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* Copyright (C) 2016 Jack Engqvist Johansson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef INC_YUAREL_H
#define INC_YUAREL_H

#ifdef __cplusplus
extern "C" {
#endif

/**
* The struct where the parsed values will be stored:
*
* scheme ":" [ "//" ] [ username ":" password "@" ] host [ ":" port ] [ "/" ] [ path ] [ "?" query ]
*
* Note: to make sure that no strings are copied, the first slash "/" in the
* path will be used to null terminate the hostname if no port is supplied.
*/
struct yuarel {
char *scheme; /* scheme, without ":" and "//" */
char *username; /* username, default: NULL */
char *password; /* password, default: NULL */
char *host; /* hostname or IP address */
int port; /* port, default: 0 */
char *path; /* path, without leading "/", default: NULL */
char *query; /* query, default: NULL */
char *fragment; /* fragment, default: NULL */
};

/* A struct to hold the query string parameter values. */
struct yuarel_param {
char *key;
char *val;
};

/**
* Parse a URL to a struct.
*
* The URL string should be in one of the following formats:
*
* Absolute URL:
* scheme ":" [ "//" ] [ username ":" password "@" ] host [ ":" port ] [ "/" ] [ path ] [ "?" query ] [ "#" fragment ]
*
* Relative URL:
* path [ "?" query ] [ "#" fragment ]
*
* The following parts will be parsed to the corresponding struct member.
*
* *url: a pointer to the struct where to store the parsed values.
* *url_str: a pointer to the url to be parsed (null terminated). The string
* will be modified.
*
* Returns 0 on success, otherwise -1.
*/
extern int yuarel_parse(struct yuarel *url, char *url_str);

/**
* Split a path into several strings.
*
* No data is copied, the slashed are used as null terminators and then
* pointers to each path part will be stored in **parts. Double slashes will be
* treated as one.
*
* *path: the path to split. The string will be modified.
* **parts: a pointer to an array of (char *) where to store the result.
* max_parts: max number of parts to parse.
*
* Returns the number of parsed items. -1 on error.
*/
extern int yuarel_split_path(char *path, char **parts, int max_parts);

/**
* Parse a query string into a key/value struct.
*
* The query string should be a null terminated string of parameters separated by
* a delimiter. Each parameter are checked for the equal sign character. If it
* appears in the parameter, it will be used as a null terminator and the part
* that comes after it will be the value of the parameter.
*
* No data are copied, the equal sign and delimiters are used as null
* terminators and then pointers to each parameter key and value will be stored
* in the yuarel_param struct.
*
* *query: the query string to parse. The string will be modified.
* delimiter: the character that separates the key/value pairs from eachother.
* *params: an array of (struct yuarel_param) where to store the result.
* max_values: max number of parameters to parse.
*
* Returns the number of parsed items. -1 on error.
*/
extern int yuarel_parse_query(char *query, char delimiter, struct yuarel_param *params, int max_params);

#ifdef __cplusplus
}
#endif

#endif /* INC_YUAREL_H */
160 changes: 80 additions & 80 deletions Inc/fatfs.h
Original file line number Diff line number Diff line change
@@ -1,80 +1,80 @@
/**
******************************************************************************
* @file fatfs.h
* @brief Header for fatfs applications
******************************************************************************
* This notice applies to any and all portions of this file
* that are not between comment pairs USER CODE BEGIN and
* USER CODE END. Other portions of this file, whether
* inserted by the user or by software development tools
* are owned by their respective copyright owners.
*
* Copyright (c) 2018 STMicroelectronics International N.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted, provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of other
* contributors to this software may be used to endorse or promote products
* derived from this software without specific written permission.
* 4. This software, including modifications and/or derivative works of this
* software, must execute solely and exclusively on microcontroller or
* microprocessor devices manufactured by or for STMicroelectronics.
* 5. Redistribution and use of this software other than as permitted under
* this license is void and will automatically terminate your rights under
* this license.
*
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __fatfs_H
#define __fatfs_H
#ifdef __cplusplus
extern "C" {
#endif
#include "ff.h"
#include "ff_gen_drv.h"
#include "usbh_diskio.h" /* defines USBH_Driver as external */
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
extern uint8_t retUSBH; /* Return value for USBH */
extern char USBHPath[4]; /* USBH logical drive path */
extern FATFS USBHFatFS; /* File system object for USBH logical drive */
extern FIL USBHFile; /* File object for USBH */
void MX_FATFS_Init(void);
/* USER CODE BEGIN Prototypes */
void usb_ls();
int usb_write(const void *bytes, size_t size);
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /*__fatfs_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
/**
******************************************************************************
* @file fatfs.h
* @brief Header for fatfs applications
******************************************************************************
* This notice applies to any and all portions of this file
* that are not between comment pairs USER CODE BEGIN and
* USER CODE END. Other portions of this file, whether
* inserted by the user or by software development tools
* are owned by their respective copyright owners.
*
* Copyright (c) 2018 STMicroelectronics International N.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted, provided that the following conditions are met:
*
* 1. Redistribution of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of other
* contributors to this software may be used to endorse or promote products
* derived from this software without specific written permission.
* 4. This software, including modifications and/or derivative works of this
* software, must execute solely and exclusively on microcontroller or
* microprocessor devices manufactured by or for STMicroelectronics.
* 5. Redistribution and use of this software other than as permitted under
* this license is void and will automatically terminate your rights under
* this license.
*
* THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY
* RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT
* SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __fatfs_H
#define __fatfs_H
#ifdef __cplusplus
extern "C" {
#endif

#include "ff.h"
#include "ff_gen_drv.h"
#include "usbh_diskio.h" /* defines USBH_Driver as external */

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern uint8_t retUSBH; /* Return value for USBH */
extern char USBHPath[4]; /* USBH logical drive path */
extern FATFS USBHFatFS; /* File system object for USBH logical drive */
extern FIL USBHFile; /* File object for USBH */

void MX_FATFS_Init(void);

/* USER CODE BEGIN Prototypes */
void usb_ls();
int usb_write(const void *bytes, const char *filename, size_t size);
/* USER CODE END Prototypes */
#ifdef __cplusplus
}
#endif
#endif /*__fatfs_H */

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Loading