send GPS data via LoRaWAN

Dependencies:   TinyGPS mbed ADXL345_I2C Sht31

Committer:
koyo_take
Date:
Sun Jun 25 00:04:16 2017 +0000
Revision:
2:829187d4fd5e
Parent:
1:195da8230785
add samples to use sensors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
koyo_take 0:97a57be77fbb 1 #if !defined(EEAPP1_H)
koyo_take 0:97a57be77fbb 2 #define EEAPP1_H
koyo_take 0:97a57be77fbb 3 #include "mbed.h"
koyo_take 0:97a57be77fbb 4 #include "types.h"
koyo_take 1:195da8230785 5 #include "Sht31.h"
koyo_take 1:195da8230785 6 #include "ADXL345_I2C.h"
koyo_take 0:97a57be77fbb 7
koyo_take 1:195da8230785 8 typedef enum {
koyo_take 0:97a57be77fbb 9 LED_OFF,
koyo_take 0:97a57be77fbb 10 LED_ON,
koyo_take 0:97a57be77fbb 11 LED_BLINK_FAST,
koyo_take 0:97a57be77fbb 12 LED_BLINK_MID,
koyo_take 0:97a57be77fbb 13 LED_BLINK_SLOW,
koyo_take 1:195da8230785 14 }EeabLedState;
koyo_take 1:195da8230785 15
koyo_take 1:195da8230785 16 typedef enum {
koyo_take 1:195da8230785 17 GROVE_CH1,
koyo_take 1:195da8230785 18 GROVE_CH2,
koyo_take 1:195da8230785 19 }EeabGrovePort;
koyo_take 1:195da8230785 20
koyo_take 1:195da8230785 21 typedef enum {
koyo_take 1:195da8230785 22 GROVE_SIG1,
koyo_take 1:195da8230785 23 GROVE_SIG2,
koyo_take 1:195da8230785 24 }EeabGroveSig;
koyo_take 1:195da8230785 25
koyo_take 1:195da8230785 26 typedef enum {
koyo_take 1:195da8230785 27 GROVE_DIO,
koyo_take 1:195da8230785 28 GROVE_ANALOG,
koyo_take 1:195da8230785 29 }EeabGrovePortType;
koyo_take 1:195da8230785 30
koyo_take 1:195da8230785 31 typedef enum {
koyo_take 1:195da8230785 32 GROVE_DIO_OUT,
koyo_take 1:195da8230785 33 GROVE_DIO_IN,
koyo_take 1:195da8230785 34 }EeabGroveDioDirection;
koyo_take 1:195da8230785 35
koyo_take 1:195da8230785 36 typedef enum {
koyo_take 1:195da8230785 37 GROVE_DIO_LOW = 0,
koyo_take 1:195da8230785 38 GROVE_DIO_HIGH = 1,
koyo_take 1:195da8230785 39 }EeabGroveDio;
koyo_take 0:97a57be77fbb 40
koyo_take 0:97a57be77fbb 41 class Eeabp1
koyo_take 0:97a57be77fbb 42 {
koyo_take 0:97a57be77fbb 43 public:
koyo_take 0:97a57be77fbb 44 Eeabp1();
koyo_take 0:97a57be77fbb 45 int setLedState(EeabLedState state);
koyo_take 0:97a57be77fbb 46 void loop(void);
koyo_take 0:97a57be77fbb 47 int debug(const char * format, ...);
koyo_take 0:97a57be77fbb 48 int setLoRaPower(bool on);
koyo_take 0:97a57be77fbb 49 int sendLoRaString(const char * format, ...);
koyo_take 0:97a57be77fbb 50 void setGrovePower(bool on);
koyo_take 1:195da8230785 51 int setGrovePortType(EeabGrovePort port, EeabGrovePortType type);
koyo_take 1:195da8230785 52 int setGroveDioDirection(EeabGrovePort port, EeabGroveDioDirection dir, Callback<void()> func = NULL);
koyo_take 1:195da8230785 53 int setGroveDio(EeabGrovePort port, EeabGroveDio val);
koyo_take 1:195da8230785 54 int getGroveDio(EeabGrovePort port, EeabGroveSig sig);
koyo_take 1:195da8230785 55 float getGroveAnalog(EeabGrovePort port, EeabGroveSig sig);
koyo_take 1:195da8230785 56 int enableTempHumidSensor(void);
koyo_take 1:195da8230785 57 float getTemp(void);
koyo_take 1:195da8230785 58 float getHumid(void);
koyo_take 1:195da8230785 59 int enableAccelerometer(void);
koyo_take 1:195da8230785 60 int getAcc(int *x, int *y, int *z);
koyo_take 0:97a57be77fbb 61
koyo_take 0:97a57be77fbb 62 private:
koyo_take 0:97a57be77fbb 63 DigitalOut pwr_en;
koyo_take 0:97a57be77fbb 64 /* state LED */
koyo_take 0:97a57be77fbb 65 DigitalOut led;
koyo_take 0:97a57be77fbb 66 EeabLedState led_state;
koyo_take 0:97a57be77fbb 67 /* LoRa */
koyo_take 0:97a57be77fbb 68 RawSerial *serial;
koyo_take 0:97a57be77fbb 69 DigitalOut lora_power;
koyo_take 0:97a57be77fbb 70 DigitalOut lora_reset;
koyo_take 0:97a57be77fbb 71 bool lora_enabled;
koyo_take 0:97a57be77fbb 72 /* Grove */
koyo_take 0:97a57be77fbb 73 DigitalOut grove_power;
koyo_take 0:97a57be77fbb 74 bool grove_enabled;
koyo_take 1:195da8230785 75 DigitalOut grv_sel2a;
koyo_take 1:195da8230785 76 DigitalOut grv_sel2g;
koyo_take 1:195da8230785 77 DigitalOut grv_sel1a;
koyo_take 1:195da8230785 78 DigitalOut grv_sel1g;
koyo_take 1:195da8230785 79
koyo_take 1:195da8230785 80 DigitalOut *grv_p1s1do; //Port1, Signal1, Digital Out // GP2
koyo_take 1:195da8230785 81 DigitalOut *grv_p1s2do; //Port1, Signal2, Digital Out // GP1
koyo_take 1:195da8230785 82 InterruptIn *grv_p1s1di; //Port1, Signal1, Digital In // GP2
koyo_take 1:195da8230785 83 InterruptIn *grv_p1s2di; //Port1, Signal1, Digital In // GP2
koyo_take 1:195da8230785 84 AnalogIn grv_p1s1a; //Port1, Signal1, Analog In // AN2
koyo_take 1:195da8230785 85 AnalogIn grv_p1s2a; //Port1, Signal2, Analog In // AN2
koyo_take 1:195da8230785 86
koyo_take 1:195da8230785 87 DigitalOut *grv_p2s1do; //Port2, Signal1, Digital Out // GP4
koyo_take 1:195da8230785 88 DigitalOut *grv_p2s2do; //Port2, Signal2, Digital Out // GP3
koyo_take 1:195da8230785 89 InterruptIn *grv_p2s1di; //Port2, Signal1, Digital In // GP4
koyo_take 1:195da8230785 90 InterruptIn *grv_p2s2di; //Port2, Signal2, Digital In // GP3
koyo_take 1:195da8230785 91 AnalogIn grv_p2s1a; //Port2, Signal1, Analog In // AN4
koyo_take 1:195da8230785 92 AnalogIn grv_p2s2a; //Port2, Signal2, Analog In // AN3
koyo_take 1:195da8230785 93
koyo_take 1:195da8230785 94 Sht31 *temp_humid_sensor;
koyo_take 1:195da8230785 95 ADXL345_I2C *accelerometer;
koyo_take 0:97a57be77fbb 96
koyo_take 0:97a57be77fbb 97 void flushSerial();
koyo_take 0:97a57be77fbb 98 int chkSerialChar(const char,uint16_t);
koyo_take 0:97a57be77fbb 99 int waitSerialChar(const char,uint16_t);
koyo_take 0:97a57be77fbb 100 int chkSerialCharOk();
koyo_take 0:97a57be77fbb 101 int chkSerialCharRes(char);
koyo_take 0:97a57be77fbb 102 };
koyo_take 0:97a57be77fbb 103
koyo_take 0:97a57be77fbb 104 #endif /* !defined(EEAPP1_H) */