GPS working with LoRa code - can't transmit faster that once every 6 seconds

Dependencies:   mbed LoRaWAN-lib_gps_lora SingleFrequencyLora

Committer:
Rishin
Date:
Fri Nov 24 15:20:12 2017 +0000
Revision:
13:66d854ad31d8
Valid GPS data sent over LoRa for roughly 7 mins with no crash

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rishin 13:66d854ad31d8 1 /*
Rishin 13:66d854ad31d8 2 ---------------------------------------------------------------------------
Rishin 13:66d854ad31d8 3 Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.
Rishin 13:66d854ad31d8 4
Rishin 13:66d854ad31d8 5 LICENSE TERMS
Rishin 13:66d854ad31d8 6
Rishin 13:66d854ad31d8 7 The redistribution and use of this software (with or without changes)
Rishin 13:66d854ad31d8 8 is allowed without the payment of fees or royalties provided that:
Rishin 13:66d854ad31d8 9
Rishin 13:66d854ad31d8 10 1. source code distributions include the above copyright notice, this
Rishin 13:66d854ad31d8 11 list of conditions and the following disclaimer;
Rishin 13:66d854ad31d8 12
Rishin 13:66d854ad31d8 13 2. binary distributions include the above copyright notice, this list
Rishin 13:66d854ad31d8 14 of conditions and the following disclaimer in their documentation;
Rishin 13:66d854ad31d8 15
Rishin 13:66d854ad31d8 16 3. the name of the copyright holder is not used to endorse products
Rishin 13:66d854ad31d8 17 built using this software without specific written permission.
Rishin 13:66d854ad31d8 18
Rishin 13:66d854ad31d8 19 DISCLAIMER
Rishin 13:66d854ad31d8 20
Rishin 13:66d854ad31d8 21 This software is provided 'as is' with no explicit or implied warranties
Rishin 13:66d854ad31d8 22 in respect of its properties, including, but not limited to, correctness
Rishin 13:66d854ad31d8 23 and/or fitness for purpose.
Rishin 13:66d854ad31d8 24 ---------------------------------------------------------------------------
Rishin 13:66d854ad31d8 25 Issue 09/09/2006
Rishin 13:66d854ad31d8 26
Rishin 13:66d854ad31d8 27 This is an AES implementation that uses only 8-bit byte operations on the
Rishin 13:66d854ad31d8 28 cipher state.
Rishin 13:66d854ad31d8 29 */
Rishin 13:66d854ad31d8 30
Rishin 13:66d854ad31d8 31 #ifndef AES_H
Rishin 13:66d854ad31d8 32 #define AES_H
Rishin 13:66d854ad31d8 33
Rishin 13:66d854ad31d8 34 #if 1
Rishin 13:66d854ad31d8 35 # define AES_ENC_PREKEYED /* AES encryption with a precomputed key schedule */
Rishin 13:66d854ad31d8 36 #endif
Rishin 13:66d854ad31d8 37 #if 0
Rishin 13:66d854ad31d8 38 # define AES_DEC_PREKEYED /* AES decryption with a precomputed key schedule */
Rishin 13:66d854ad31d8 39 #endif
Rishin 13:66d854ad31d8 40 #if 0
Rishin 13:66d854ad31d8 41 # define AES_ENC_128_OTFK /* AES encryption with 'on the fly' 128 bit keying */
Rishin 13:66d854ad31d8 42 #endif
Rishin 13:66d854ad31d8 43 #if 0
Rishin 13:66d854ad31d8 44 # define AES_DEC_128_OTFK /* AES decryption with 'on the fly' 128 bit keying */
Rishin 13:66d854ad31d8 45 #endif
Rishin 13:66d854ad31d8 46 #if 0
Rishin 13:66d854ad31d8 47 # define AES_ENC_256_OTFK /* AES encryption with 'on the fly' 256 bit keying */
Rishin 13:66d854ad31d8 48 #endif
Rishin 13:66d854ad31d8 49 #if 0
Rishin 13:66d854ad31d8 50 # define AES_DEC_256_OTFK /* AES decryption with 'on the fly' 256 bit keying */
Rishin 13:66d854ad31d8 51 #endif
Rishin 13:66d854ad31d8 52
Rishin 13:66d854ad31d8 53 #define N_ROW 4
Rishin 13:66d854ad31d8 54 #define N_COL 4
Rishin 13:66d854ad31d8 55 #define N_BLOCK (N_ROW * N_COL)
Rishin 13:66d854ad31d8 56 #define N_MAX_ROUNDS 14
Rishin 13:66d854ad31d8 57
Rishin 13:66d854ad31d8 58 typedef uint8_t return_type;
Rishin 13:66d854ad31d8 59
Rishin 13:66d854ad31d8 60 /* Warning: The key length for 256 bit keys overflows a byte
Rishin 13:66d854ad31d8 61 (see comment below)
Rishin 13:66d854ad31d8 62 */
Rishin 13:66d854ad31d8 63
Rishin 13:66d854ad31d8 64 typedef uint8_t length_type;
Rishin 13:66d854ad31d8 65
Rishin 13:66d854ad31d8 66 typedef struct
Rishin 13:66d854ad31d8 67 { uint8_t ksch[(N_MAX_ROUNDS + 1) * N_BLOCK];
Rishin 13:66d854ad31d8 68 uint8_t rnd;
Rishin 13:66d854ad31d8 69 } aes_context;
Rishin 13:66d854ad31d8 70
Rishin 13:66d854ad31d8 71 /* The following calls are for a precomputed key schedule
Rishin 13:66d854ad31d8 72
Rishin 13:66d854ad31d8 73 NOTE: If the length_type used for the key length is an
Rishin 13:66d854ad31d8 74 unsigned 8-bit character, a key length of 256 bits must
Rishin 13:66d854ad31d8 75 be entered as a length in bytes (valid inputs are hence
Rishin 13:66d854ad31d8 76 128, 192, 16, 24 and 32).
Rishin 13:66d854ad31d8 77 */
Rishin 13:66d854ad31d8 78
Rishin 13:66d854ad31d8 79 #if defined( AES_ENC_PREKEYED ) || defined( AES_DEC_PREKEYED )
Rishin 13:66d854ad31d8 80
Rishin 13:66d854ad31d8 81 return_type aes_set_key( const uint8_t key[],
Rishin 13:66d854ad31d8 82 length_type keylen,
Rishin 13:66d854ad31d8 83 aes_context ctx[1] );
Rishin 13:66d854ad31d8 84 #endif
Rishin 13:66d854ad31d8 85
Rishin 13:66d854ad31d8 86 #if defined( AES_ENC_PREKEYED )
Rishin 13:66d854ad31d8 87
Rishin 13:66d854ad31d8 88 return_type aes_encrypt( const uint8_t in[N_BLOCK],
Rishin 13:66d854ad31d8 89 uint8_t out[N_BLOCK],
Rishin 13:66d854ad31d8 90 const aes_context ctx[1] );
Rishin 13:66d854ad31d8 91
Rishin 13:66d854ad31d8 92 return_type aes_cbc_encrypt( const uint8_t *in,
Rishin 13:66d854ad31d8 93 uint8_t *out,
Rishin 13:66d854ad31d8 94 int32_t n_block,
Rishin 13:66d854ad31d8 95 uint8_t iv[N_BLOCK],
Rishin 13:66d854ad31d8 96 const aes_context ctx[1] );
Rishin 13:66d854ad31d8 97 #endif
Rishin 13:66d854ad31d8 98
Rishin 13:66d854ad31d8 99 #if defined( AES_DEC_PREKEYED )
Rishin 13:66d854ad31d8 100
Rishin 13:66d854ad31d8 101 return_type aes_decrypt( const uint8_t in[N_BLOCK],
Rishin 13:66d854ad31d8 102 uint8_t out[N_BLOCK],
Rishin 13:66d854ad31d8 103 const aes_context ctx[1] );
Rishin 13:66d854ad31d8 104
Rishin 13:66d854ad31d8 105 return_type aes_cbc_decrypt( const uint8_t *in,
Rishin 13:66d854ad31d8 106 uint8_t *out,
Rishin 13:66d854ad31d8 107 int32_t n_block,
Rishin 13:66d854ad31d8 108 uint8_t iv[N_BLOCK],
Rishin 13:66d854ad31d8 109 const aes_context ctx[1] );
Rishin 13:66d854ad31d8 110 #endif
Rishin 13:66d854ad31d8 111
Rishin 13:66d854ad31d8 112 /* The following calls are for 'on the fly' keying. In this case the
Rishin 13:66d854ad31d8 113 encryption and decryption keys are different.
Rishin 13:66d854ad31d8 114
Rishin 13:66d854ad31d8 115 The encryption subroutines take a key in an array of bytes in
Rishin 13:66d854ad31d8 116 key[L] where L is 16, 24 or 32 bytes for key lengths of 128,
Rishin 13:66d854ad31d8 117 192, and 256 bits respectively. They then encrypts the input
Rishin 13:66d854ad31d8 118 data, in[] with this key and put the reult in the output array
Rishin 13:66d854ad31d8 119 out[]. In addition, the second key array, o_key[L], is used
Rishin 13:66d854ad31d8 120 to output the key that is needed by the decryption subroutine
Rishin 13:66d854ad31d8 121 to reverse the encryption operation. The two key arrays can
Rishin 13:66d854ad31d8 122 be the same array but in this case the original key will be
Rishin 13:66d854ad31d8 123 overwritten.
Rishin 13:66d854ad31d8 124
Rishin 13:66d854ad31d8 125 In the same way, the decryption subroutines output keys that
Rishin 13:66d854ad31d8 126 can be used to reverse their effect when used for encryption.
Rishin 13:66d854ad31d8 127
Rishin 13:66d854ad31d8 128 Only 128 and 256 bit keys are supported in these 'on the fly'
Rishin 13:66d854ad31d8 129 modes.
Rishin 13:66d854ad31d8 130 */
Rishin 13:66d854ad31d8 131
Rishin 13:66d854ad31d8 132 #if defined( AES_ENC_128_OTFK )
Rishin 13:66d854ad31d8 133 void aes_encrypt_128( const uint8_t in[N_BLOCK],
Rishin 13:66d854ad31d8 134 uint8_t out[N_BLOCK],
Rishin 13:66d854ad31d8 135 const uint8_t key[N_BLOCK],
Rishin 13:66d854ad31d8 136 uint8_t o_key[N_BLOCK] );
Rishin 13:66d854ad31d8 137 #endif
Rishin 13:66d854ad31d8 138
Rishin 13:66d854ad31d8 139 #if defined( AES_DEC_128_OTFK )
Rishin 13:66d854ad31d8 140 void aes_decrypt_128( const uint8_t in[N_BLOCK],
Rishin 13:66d854ad31d8 141 uint8_t out[N_BLOCK],
Rishin 13:66d854ad31d8 142 const uint8_t key[N_BLOCK],
Rishin 13:66d854ad31d8 143 uint8_t o_key[N_BLOCK] );
Rishin 13:66d854ad31d8 144 #endif
Rishin 13:66d854ad31d8 145
Rishin 13:66d854ad31d8 146 #if defined( AES_ENC_256_OTFK )
Rishin 13:66d854ad31d8 147 void aes_encrypt_256( const uint8_t in[N_BLOCK],
Rishin 13:66d854ad31d8 148 uint8_t out[N_BLOCK],
Rishin 13:66d854ad31d8 149 const uint8_t key[2 * N_BLOCK],
Rishin 13:66d854ad31d8 150 uint8_t o_key[2 * N_BLOCK] );
Rishin 13:66d854ad31d8 151 #endif
Rishin 13:66d854ad31d8 152
Rishin 13:66d854ad31d8 153 #if defined( AES_DEC_256_OTFK )
Rishin 13:66d854ad31d8 154 void aes_decrypt_256( const uint8_t in[N_BLOCK],
Rishin 13:66d854ad31d8 155 uint8_t out[N_BLOCK],
Rishin 13:66d854ad31d8 156 const uint8_t key[2 * N_BLOCK],
Rishin 13:66d854ad31d8 157 uint8_t o_key[2 * N_BLOCK] );
Rishin 13:66d854ad31d8 158 #endif
Rishin 13:66d854ad31d8 159
Rishin 13:66d854ad31d8 160 #endif