Fork of my original MQTTGateway

Dependencies:   mbed-http

Committer:
vpcola
Date:
Sat Apr 08 14:43:14 2017 +0000
Revision:
0:a1734fe1ec4b
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
vpcola 0:a1734fe1ec4b 1 /*
vpcola 0:a1734fe1ec4b 2 * Copyright (c) 2012, STMicroelectronics.
vpcola 0:a1734fe1ec4b 3 * All rights reserved.
vpcola 0:a1734fe1ec4b 4 *
vpcola 0:a1734fe1ec4b 5 * Redistribution and use in source and binary forms, with or without
vpcola 0:a1734fe1ec4b 6 * modification, are permitted provided that the following conditions
vpcola 0:a1734fe1ec4b 7 * are met:
vpcola 0:a1734fe1ec4b 8 * 1. Redistributions of source code must retain the above copyright
vpcola 0:a1734fe1ec4b 9 * notice, this list of conditions and the following disclaimer.
vpcola 0:a1734fe1ec4b 10 * 2. Redistributions in binary form must reproduce the above copyright
vpcola 0:a1734fe1ec4b 11 * notice, this list of conditions and the following disclaimer in the
vpcola 0:a1734fe1ec4b 12 * documentation and/or other materials provided with the distribution.
vpcola 0:a1734fe1ec4b 13 * 3. Neither the name of the Institute nor the names of its contributors
vpcola 0:a1734fe1ec4b 14 * may be used to endorse or promote products derived from this software
vpcola 0:a1734fe1ec4b 15 * without specific prior written permission.
vpcola 0:a1734fe1ec4b 16 *
vpcola 0:a1734fe1ec4b 17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
vpcola 0:a1734fe1ec4b 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
vpcola 0:a1734fe1ec4b 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
vpcola 0:a1734fe1ec4b 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
vpcola 0:a1734fe1ec4b 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
vpcola 0:a1734fe1ec4b 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
vpcola 0:a1734fe1ec4b 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
vpcola 0:a1734fe1ec4b 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
vpcola 0:a1734fe1ec4b 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
vpcola 0:a1734fe1ec4b 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
vpcola 0:a1734fe1ec4b 27 * SUCH DAMAGE.
vpcola 0:a1734fe1ec4b 28 *
vpcola 0:a1734fe1ec4b 29 * This file is part of the Contiki operating system.
vpcola 0:a1734fe1ec4b 30 *
vpcola 0:a1734fe1ec4b 31 */
vpcola 0:a1734fe1ec4b 32 /*---------------------------------------------------------------------------*/
vpcola 0:a1734fe1ec4b 33 #ifndef __SPIRIT_H__
vpcola 0:a1734fe1ec4b 34 #define __SPIRIT_H__
vpcola 0:a1734fe1ec4b 35 /*---------------------------------------------------------------------------*/
vpcola 0:a1734fe1ec4b 36 #include "radio.h"
vpcola 0:a1734fe1ec4b 37 #include "SPIRIT_Config.h"
vpcola 0:a1734fe1ec4b 38 #include "spirit1-config.h"
vpcola 0:a1734fe1ec4b 39 //#include "spirit1_appli.h"
vpcola 0:a1734fe1ec4b 40 #include "spirit1-const.h"
vpcola 0:a1734fe1ec4b 41 /*---------------------------------------------------------------------------*/
vpcola 0:a1734fe1ec4b 42 extern const struct radio_driver spirit_radio_driver;
vpcola 0:a1734fe1ec4b 43 void spirit1_interrupt_callback(void);
vpcola 0:a1734fe1ec4b 44
vpcola 0:a1734fe1ec4b 45 /* exported from spirit1appli.h */
vpcola 0:a1734fe1ec4b 46
vpcola 0:a1734fe1ec4b 47 #include "radio_shield_config.h"
vpcola 0:a1734fe1ec4b 48 #include "MCU_Interface.h"
vpcola 0:a1734fe1ec4b 49 #include "SPIRIT_Config.h"
vpcola 0:a1734fe1ec4b 50 // betzw - WAS: #include "SPIRIT1_Util.h"
vpcola 0:a1734fe1ec4b 51
vpcola 0:a1734fe1ec4b 52
vpcola 0:a1734fe1ec4b 53 #if defined(X_NUCLEO_IDS01A3)
vpcola 0:a1734fe1ec4b 54 #define USE_SPIRIT1_433MHz
vpcola 0:a1734fe1ec4b 55 #elif defined(X_NUCLEO_IDS01A4)
vpcola 0:a1734fe1ec4b 56 #define USE_SPIRIT1_868MHz
vpcola 0:a1734fe1ec4b 57 #elif defined(X_NUCLEO_IDS01A5)
vpcola 0:a1734fe1ec4b 58 #define USE_SPIRIT1_915MHz
vpcola 0:a1734fe1ec4b 59 #else
vpcola 0:a1734fe1ec4b 60 #error SPIRIT1 Nucleo Shield undefined or unsupported
vpcola 0:a1734fe1ec4b 61 #endif
vpcola 0:a1734fe1ec4b 62
vpcola 0:a1734fe1ec4b 63 /* Uncomment the Link Layer features to be used */
vpcola 0:a1734fe1ec4b 64 // #define USE_AUTO_ACK
vpcola 0:a1734fe1ec4b 65 // #define USE_AUTO_ACK_PIGGYBACKING
vpcola 0:a1734fe1ec4b 66 // #define USE_AUTO_RETRANSMISSION
vpcola 0:a1734fe1ec4b 67
vpcola 0:a1734fe1ec4b 68 #if defined(USE_AUTO_ACK)&& defined(USE_AUTO_ACK_PIGGYBACKING)&& defined(USE_AUTO_RETRANSMISSION)
vpcola 0:a1734fe1ec4b 69 #define USE_STack_PROTOCOL
vpcola 0:a1734fe1ec4b 70
vpcola 0:a1734fe1ec4b 71 /* LLP configuration parameters */
vpcola 0:a1734fe1ec4b 72 #define EN_AUTOACK S_ENABLE
vpcola 0:a1734fe1ec4b 73 #define EN_PIGGYBACKING S_ENABLE
vpcola 0:a1734fe1ec4b 74 #define MAX_RETRANSMISSIONS PKT_N_RETX_2
vpcola 0:a1734fe1ec4b 75
vpcola 0:a1734fe1ec4b 76 #else
vpcola 0:a1734fe1ec4b 77 #define USE_BASIC_PROTOCOL
vpcola 0:a1734fe1ec4b 78
vpcola 0:a1734fe1ec4b 79 #endif
vpcola 0:a1734fe1ec4b 80
vpcola 0:a1734fe1ec4b 81 /* Uncomment the system Operating mode */
vpcola 0:a1734fe1ec4b 82 //#define USE_LOW_POWER_MODE
vpcola 0:a1734fe1ec4b 83
vpcola 0:a1734fe1ec4b 84 #if defined (USE_LOW_POWER_MODE)
vpcola 0:a1734fe1ec4b 85 #define LPM_ENABLE
vpcola 0:a1734fe1ec4b 86 #define MCU_STOP_MODE
vpcola 0:a1734fe1ec4b 87 //#define MCU_SLEEP_MODE
vpcola 0:a1734fe1ec4b 88 //#define RF_STANDBY
vpcola 0:a1734fe1ec4b 89 #endif
vpcola 0:a1734fe1ec4b 90
vpcola 0:a1734fe1ec4b 91
vpcola 0:a1734fe1ec4b 92 /* Exported constants --------------------------------------------------------*/
vpcola 0:a1734fe1ec4b 93
vpcola 0:a1734fe1ec4b 94 /* Radio configuration parameters */
vpcola 0:a1734fe1ec4b 95 #define XTAL_OFFSET_PPM 0
vpcola 0:a1734fe1ec4b 96 #define INFINITE_TIMEOUT 0.0
vpcola 0:a1734fe1ec4b 97
vpcola 0:a1734fe1ec4b 98 #ifdef USE_SPIRIT1_433MHz
vpcola 0:a1734fe1ec4b 99 #define BASE_FREQUENCY 433.0e6
vpcola 0:a1734fe1ec4b 100 #endif
vpcola 0:a1734fe1ec4b 101
vpcola 0:a1734fe1ec4b 102 #ifdef USE_SPIRIT1_868MHz
vpcola 0:a1734fe1ec4b 103 #define BASE_FREQUENCY 868.0e6
vpcola 0:a1734fe1ec4b 104 #endif
vpcola 0:a1734fe1ec4b 105
vpcola 0:a1734fe1ec4b 106 #ifdef USE_SPIRIT1_915MHz
vpcola 0:a1734fe1ec4b 107 //#define BASE_FREQUENCY 915.0e6
vpcola 0:a1734fe1ec4b 108 #define BASE_FREQUENCY 902.0e6
vpcola 0:a1734fe1ec4b 109 #endif
vpcola 0:a1734fe1ec4b 110
vpcola 0:a1734fe1ec4b 111
vpcola 0:a1734fe1ec4b 112 /* Addresses configuration parameters */
vpcola 0:a1734fe1ec4b 113 #define EN_FILT_MY_ADDRESS S_DISABLE
vpcola 0:a1734fe1ec4b 114 #define MY_ADDRESS 0x24
vpcola 0:a1734fe1ec4b 115 #define EN_FILT_MULTICAST_ADDRESS S_DISABLE
vpcola 0:a1734fe1ec4b 116 #define MULTICAST_ADDRESS 0xEE
vpcola 0:a1734fe1ec4b 117 #define EN_FILT_BROADCAST_ADDRESS S_DISABLE
vpcola 0:a1734fe1ec4b 118 #define BROADCAST_ADDRESS 0xFF
vpcola 0:a1734fe1ec4b 119 #define DESTINATION_ADDRESS 0x44
vpcola 0:a1734fe1ec4b 120 #define EN_FILT_SOURCE_ADDRESS S_DISABLE
vpcola 0:a1734fe1ec4b 121 #define SOURCE_ADDR_MASK 0xf0
vpcola 0:a1734fe1ec4b 122 #define SOURCE_ADDR_REF 0x37
vpcola 0:a1734fe1ec4b 123
vpcola 0:a1734fe1ec4b 124 #define APPLI_CMD 0x11
vpcola 0:a1734fe1ec4b 125 #define NWK_CMD 0x22
vpcola 0:a1734fe1ec4b 126 #define LED_TOGGLE 0xff
vpcola 0:a1734fe1ec4b 127 #define ACK_OK 0x01
vpcola 0:a1734fe1ec4b 128 #define MAX_BUFFER_LEN 96
vpcola 0:a1734fe1ec4b 129 #define TIME_TO_EXIT_RX 3000
vpcola 0:a1734fe1ec4b 130 #define DELAY_RX_LED_TOGGLE 200
vpcola 0:a1734fe1ec4b 131 #define DELAY_TX_LED_GLOW 1000
vpcola 0:a1734fe1ec4b 132 #define LPM_WAKEUP_TIME 100
vpcola 0:a1734fe1ec4b 133 #define DATA_SEND_TIME 30
vpcola 0:a1734fe1ec4b 134
vpcola 0:a1734fe1ec4b 135 #define PREAMBLE_LENGTH PKT_PREAMBLE_LENGTH_04BYTES
vpcola 0:a1734fe1ec4b 136 #define SYNC_LENGTH PKT_SYNC_LENGTH_4BYTES
vpcola 0:a1734fe1ec4b 137 #define CONTROL_LENGTH PKT_CONTROL_LENGTH_0BYTES
vpcola 0:a1734fe1ec4b 138 #define EN_ADDRESS S_DISABLE
vpcola 0:a1734fe1ec4b 139 #define EN_FEC S_DISABLE
vpcola 0:a1734fe1ec4b 140 #define CHANNEL_NUMBER 1 // betzw - WAS: 0
vpcola 0:a1734fe1ec4b 141 #define LENGTH_TYPE PKT_LENGTH_VAR
vpcola 0:a1734fe1ec4b 142 #define POWER_INDEX 7
vpcola 0:a1734fe1ec4b 143 #define RECEIVE_TIMEOUT 2000.0 /*change the value for required timeout period*/
vpcola 0:a1734fe1ec4b 144 #define RSSI_THRESHOLD -120
vpcola 0:a1734fe1ec4b 145
vpcola 0:a1734fe1ec4b 146
vpcola 0:a1734fe1ec4b 147
vpcola 0:a1734fe1ec4b 148 #define POWER_DBM 11.6
vpcola 0:a1734fe1ec4b 149 #define CHANNEL_SPACE 100e3
vpcola 0:a1734fe1ec4b 150 #define FREQ_DEVIATION 127e3
vpcola 0:a1734fe1ec4b 151 #define BANDWIDTH 540.0e3
vpcola 0:a1734fe1ec4b 152 #define MODULATION_SELECT GFSK_BT1
vpcola 0:a1734fe1ec4b 153 #define DATARATE 250000
vpcola 0:a1734fe1ec4b 154 #define XTAL_OFFSET_PPM 0
vpcola 0:a1734fe1ec4b 155 #define SYNC_WORD 0x88888888
vpcola 0:a1734fe1ec4b 156 #define LENGTH_WIDTH 8 // betzw - NOTE: only 255 bytes for payload!!!
vpcola 0:a1734fe1ec4b 157 #define CRC_MODE PKT_CRC_MODE_16BITS_2
vpcola 0:a1734fe1ec4b 158 #define EN_WHITENING S_DISABLE
vpcola 0:a1734fe1ec4b 159 #define INFINITE_TIMEOUT 0.0
vpcola 0:a1734fe1ec4b 160
vpcola 0:a1734fe1ec4b 161 // extern volatile FlagStatus xRxDoneFlag, xTxDoneFlag;
vpcola 0:a1734fe1ec4b 162 // extern volatile FlagStatus PushButtonStatusWakeup;
vpcola 0:a1734fe1ec4b 163 extern uint16_t wakeupCounter;
vpcola 0:a1734fe1ec4b 164 extern uint16_t dataSendCounter ;
vpcola 0:a1734fe1ec4b 165 // extern volatile FlagStatus PushButtonStatusData, datasendFlag;
vpcola 0:a1734fe1ec4b 166
vpcola 0:a1734fe1ec4b 167 typedef struct
vpcola 0:a1734fe1ec4b 168 {
vpcola 0:a1734fe1ec4b 169 uint8_t Cmdtag;
vpcola 0:a1734fe1ec4b 170 uint8_t CmdType;
vpcola 0:a1734fe1ec4b 171 uint8_t CmdLen;
vpcola 0:a1734fe1ec4b 172 uint8_t Cmd;
vpcola 0:a1734fe1ec4b 173 uint8_t DataLen;
vpcola 0:a1734fe1ec4b 174 uint8_t* DataBuff;
vpcola 0:a1734fe1ec4b 175 }AppliFrame_t;
vpcola 0:a1734fe1ec4b 176
vpcola 0:a1734fe1ec4b 177 /*---------------------------------------------------------------------------*/
vpcola 0:a1734fe1ec4b 178 #endif /* __SPIRIT_H__ */
vpcola 0:a1734fe1ec4b 179 /*---------------------------------------------------------------------------*/