ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Committer:
TMBOY
Date:
Tue Jul 18 16:54:45 2017 +0800
Revision:
47:9e361da97763
?

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TMBOY 47:9e361da97763 1
TMBOY 47:9e361da97763 2 #ifndef _MBED_PACK_INCLUDE_
TMBOY 47:9e361da97763 3 #define _MBED_PACK_INCLUDE_
TMBOY 47:9e361da97763 4
TMBOY 47:9e361da97763 5 #ifdef __cplusplus
TMBOY 47:9e361da97763 6 #define MBEDPACK_EXTERN extern "C"
TMBOY 47:9e361da97763 7 #else
TMBOY 47:9e361da97763 8 #define MBEDPACK_EXTERN extern
TMBOY 47:9e361da97763 9 #endif
TMBOY 47:9e361da97763 10
TMBOY 47:9e361da97763 11 #include "pack_include.h"
TMBOY 47:9e361da97763 12 #include <stdint.h>
TMBOY 47:9e361da97763 13
TMBOY 47:9e361da97763 14 ///
TMBOY 47:9e361da97763 15 /// all modules type can included in package
TMBOY 47:9e361da97763 16 /*typedef enum _module_type {
TMBOY 47:9e361da97763 17 ModuleTypeALL,
TMBOY 47:9e361da97763 18 ModuleTypeJS,
TMBOY 47:9e361da97763 19 ModuleTypeSO,
TMBOY 47:9e361da97763 20 ModuleTypeBIN,
TMBOY 47:9e361da97763 21 ModuleTypeJSON,
TMBOY 47:9e361da97763 22 ModuleTypeIMG
TMBOY 47:9e361da97763 23 } module_type_t;
TMBOY 47:9e361da97763 24 */
TMBOY 47:9e361da97763 25 ///
TMBOY 47:9e361da97763 26 /// package type : a package can contain app, os or profile
TMBOY 47:9e361da97763 27 /*typedef enum _package_type {
TMBOY 47:9e361da97763 28 PackageTypeApp,
TMBOY 47:9e361da97763 29 PackageTypeOS,
TMBOY 47:9e361da97763 30 PackageTypeProfile,
TMBOY 47:9e361da97763 31 PackageTypeUnknown
TMBOY 47:9e361da97763 32 } package_type_t;
TMBOY 47:9e361da97763 33 */
TMBOY 47:9e361da97763 34 /*
TMBOY 47:9e361da97763 35 typedef enum {
TMBOY 47:9e361da97763 36 false = 0,
TMBOY 47:9e361da97763 37 true
TMBOY 47:9e361da97763 38 } bool;*/
TMBOY 47:9e361da97763 39
TMBOY 47:9e361da97763 40
TMBOY 47:9e361da97763 41 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TMBOY 47:9e361da97763 42
TMBOY 47:9e361da97763 43
TMBOY 47:9e361da97763 44 /**
TMBOY 47:9e361da97763 45 * verification init
TMBOY 47:9e361da97763 46 *
TMBOY 47:9e361da97763 47 * \return verification context if success, or NULL
TMBOY 47:9e361da97763 48 */
TMBOY 47:9e361da97763 49 MBEDPACK_EXTERN void* mbed_verification_init();
TMBOY 47:9e361da97763 50
TMBOY 47:9e361da97763 51 /**
TMBOY 47:9e361da97763 52 * verification update context
TMBOY 47:9e361da97763 53 *
TMBOY 47:9e361da97763 54 * \param ctx verification context
TMBOY 47:9e361da97763 55 * \param buffer data to update context
TMBOY 47:9e361da97763 56 * \param buffer_size data size
TMBOY 47:9e361da97763 57 */
TMBOY 47:9e361da97763 58 MBEDPACK_EXTERN void mbed_verification_update_ctx(void* ctx, unsigned char* buffer, uint32_t buffer_size);
TMBOY 47:9e361da97763 59
TMBOY 47:9e361da97763 60 /**
TMBOY 47:9e361da97763 61 * verify
TMBOY 47:9e361da97763 62 *
TMBOY 47:9e361da97763 63 * \param ctx verification context
TMBOY 47:9e361da97763 64 *
TMBOY 47:9e361da97763 65 * \return 0 if success, or fail
TMBOY 47:9e361da97763 66 */
TMBOY 47:9e361da97763 67 MBEDPACK_EXTERN int mbed_verification(void* ctx);
TMBOY 47:9e361da97763 68
TMBOY 47:9e361da97763 69
TMBOY 47:9e361da97763 70 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TMBOY 47:9e361da97763 71
TMBOY 47:9e361da97763 72
TMBOY 47:9e361da97763 73 /**
TMBOY 47:9e361da97763 74 *
TMBOY 47:9e361da97763 75 * package decompress
TMBOY 47:9e361da97763 76 *
TMBOY 47:9e361da97763 77 * \return decompress context
TMBOY 47:9e361da97763 78 */
TMBOY 47:9e361da97763 79 MBEDPACK_EXTERN void* mbed_decompress_init();
TMBOY 47:9e361da97763 80
TMBOY 47:9e361da97763 81
TMBOY 47:9e361da97763 82 /**
TMBOY 47:9e361da97763 83 *
TMBOY 47:9e361da97763 84 * package decompress process
TMBOY 47:9e361da97763 85 *
TMBOY 47:9e361da97763 86 * \param ctx decompress context
TMBOY 47:9e361da97763 87 * \param buffer data to decompress
TMBOY 47:9e361da97763 88 * \param bufferSZ buffer size
TMBOY 47:9e361da97763 89 * \param lFileHandle fs file index
TMBOY 47:9e361da97763 90 *
TMBOY 47:9e361da97763 91 * \return process state
TMBOY 47:9e361da97763 92 */
TMBOY 47:9e361da97763 93 MBEDPACK_EXTERN int mbed_decompress_process(void * verify_cxt, void* ctx, unsigned char* buffer, uint32_t bufferSZ, struct IOtaUpdater *updater, void *update_cxt);
TMBOY 47:9e361da97763 94
TMBOY 47:9e361da97763 95
TMBOY 47:9e361da97763 96 /**
TMBOY 47:9e361da97763 97 *
TMBOY 47:9e361da97763 98 * package decompress uninit
TMBOY 47:9e361da97763 99 *
TMBOY 47:9e361da97763 100 * \param ctx decompress context
TMBOY 47:9e361da97763 101 *
TMBOY 47:9e361da97763 102 */
TMBOY 47:9e361da97763 103 MBEDPACK_EXTERN void mbed_decompress_uninit(void* ctx);
TMBOY 47:9e361da97763 104
TMBOY 47:9e361da97763 105
TMBOY 47:9e361da97763 106 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TMBOY 47:9e361da97763 107
TMBOY 47:9e361da97763 108
TMBOY 47:9e361da97763 109
TMBOY 47:9e361da97763 110 /**
TMBOY 47:9e361da97763 111 *
TMBOY 47:9e361da97763 112 * package info collector init
TMBOY 47:9e361da97763 113 *
TMBOY 47:9e361da97763 114 * \return ctx collector context
TMBOY 47:9e361da97763 115 *
TMBOY 47:9e361da97763 116 */
TMBOY 47:9e361da97763 117 MBEDPACK_EXTERN void* mbed_data_collector_init(unsigned char* filename);
TMBOY 47:9e361da97763 118
TMBOY 47:9e361da97763 119
TMBOY 47:9e361da97763 120 /**
TMBOY 47:9e361da97763 121 *
TMBOY 47:9e361da97763 122 * package info collector uninit
TMBOY 47:9e361da97763 123 *
TMBOY 47:9e361da97763 124 * \param ctx collector context
TMBOY 47:9e361da97763 125 *
TMBOY 47:9e361da97763 126 */
TMBOY 47:9e361da97763 127 MBEDPACK_EXTERN void mbed_data_collector_uninit(void* ctx);
TMBOY 47:9e361da97763 128
TMBOY 47:9e361da97763 129
TMBOY 47:9e361da97763 130 /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TMBOY 47:9e361da97763 131
TMBOY 47:9e361da97763 132 /**
TMBOY 47:9e361da97763 133 * get a certain type module count
TMBOY 47:9e361da97763 134
TMBOY 47:9e361da97763 135 *
TMBOY 47:9e361da97763 136 * \param ctx package context
TMBOY 47:9e361da97763 137 * \param type module type of js , bin or all
TMBOY 47:9e361da97763 138 * \return module count of a certain type if success, or 0
TMBOY 47:9e361da97763 139 */
TMBOY 47:9e361da97763 140 MBEDPACK_EXTERN uint8_t pkg_get_module_count(void* ctx, module_type_t type);
TMBOY 47:9e361da97763 141
TMBOY 47:9e361da97763 142
TMBOY 47:9e361da97763 143 /**
TMBOY 47:9e361da97763 144
TMBOY 47:9e361da97763 145 * get module handle
TMBOY 47:9e361da97763 146 *
TMBOY 47:9e361da97763 147 * \param ctx package context
TMBOY 47:9e361da97763 148 * \param type module type of js , bin or all
TMBOY 47:9e361da97763 149
TMBOY 47:9e361da97763 150 * \param index index of module
TMBOY 47:9e361da97763 151 * \return module handle of a certain type if success, or 0
TMBOY 47:9e361da97763 152 */
TMBOY 47:9e361da97763 153 MBEDPACK_EXTERN void* /*handle*/pkg_acquire_module(void* ctx, module_type_t type, int index);
TMBOY 47:9e361da97763 154
TMBOY 47:9e361da97763 155
TMBOY 47:9e361da97763 156 /**
TMBOY 47:9e361da97763 157 * release module handle
TMBOY 47:9e361da97763 158 *
TMBOY 47:9e361da97763 159 * \param handle module handle to release
TMBOY 47:9e361da97763 160 */
TMBOY 47:9e361da97763 161 MBEDPACK_EXTERN void pkg_release_module(void* handle);
TMBOY 47:9e361da97763 162
TMBOY 47:9e361da97763 163
TMBOY 47:9e361da97763 164 /**
TMBOY 47:9e361da97763 165 * get module name
TMBOY 47:9e361da97763 166 *
TMBOY 47:9e361da97763 167 * \param handle module handle to operate module
TMBOY 47:9e361da97763 168 * \return module name if success, or NULL
TMBOY 47:9e361da97763 169 */
TMBOY 47:9e361da97763 170 MBEDPACK_EXTERN const char* pkg_get_module_name(void* handle);
TMBOY 47:9e361da97763 171
TMBOY 47:9e361da97763 172
TMBOY 47:9e361da97763 173 /**
TMBOY 47:9e361da97763 174 * get module version : software version or hardware version
TMBOY 47:9e361da97763 175 *
TMBOY 47:9e361da97763 176 * \param handle module handle to operate module
TMBOY 47:9e361da97763 177 * \param hardware_version version caller cared
TMBOY 47:9e361da97763 178 * \return module version if success, or NULL
TMBOY 47:9e361da97763 179 */
TMBOY 47:9e361da97763 180 MBEDPACK_EXTERN const char* pkg_get_module_version(void* handle, bool hardware_version);
TMBOY 47:9e361da97763 181
TMBOY 47:9e361da97763 182
TMBOY 47:9e361da97763 183 /**
TMBOY 47:9e361da97763 184 * get module offset and size, user can read module data from fs
TMBOY 47:9e361da97763 185 *
TMBOY 47:9e361da97763 186 * \param handle module handle to operate module
TMBOY 47:9e361da97763 187 * \param offset offset to the beginning of package
TMBOY 47:9e361da97763 188 * \param size module size if success or 0
TMBOY 47:9e361da97763 189 * \return 0 if success, or fail
TMBOY 47:9e361da97763 190 */
TMBOY 47:9e361da97763 191 MBEDPACK_EXTERN int pkg_locate_module_data(void* handle, uint32_t* offset, uint32_t* size);
TMBOY 47:9e361da97763 192
TMBOY 47:9e361da97763 193 /**
TMBOY 47:9e361da97763 194 * get package name
TMBOY 47:9e361da97763 195 *
TMBOY 47:9e361da97763 196 * \param ctx package context
TMBOY 47:9e361da97763 197 * \param name package name
TMBOY 47:9e361da97763 198 * \param name_length length of name
TMBOY 47:9e361da97763 199 * \return 0 if success, 1 means no enough length buffer and return length need, or failed
TMBOY 47:9e361da97763 200 */
TMBOY 47:9e361da97763 201 MBEDPACK_EXTERN int pkg_get_pkg_name(void* ctx, unsigned char* name, uint8_t* name_length);
TMBOY 47:9e361da97763 202
TMBOY 47:9e361da97763 203 /**
TMBOY 47:9e361da97763 204 * get package type
TMBOY 47:9e361da97763 205 *
TMBOY 47:9e361da97763 206 * \param ctx package context
TMBOY 47:9e361da97763 207 * \param type package type
TMBOY 47:9e361da97763 208 * \return 0 if success, or fail
TMBOY 47:9e361da97763 209 */
TMBOY 47:9e361da97763 210 MBEDPACK_EXTERN int pkg_get_pkg_type(void* ctx, package_type_t* type);
TMBOY 47:9e361da97763 211
TMBOY 47:9e361da97763 212 #endif
TMBOY 47:9e361da97763 213
TMBOY 47:9e361da97763 214