54 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			54 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
| #ifndef LORARADIO_H
 | |
| #define LORARADIO_H
 | |
| 
 | |
| #include <lmic.h>
 | |
| #include <hal/hal.h>
 | |
| #include <SPI.h>
 | |
| #include <Arduino.h>
 | |
| /*
 | |
|  * Here, we define the onEvent function required by the LMIC
 | |
|  */
 | |
| void onEvent(ev_t ev);
 | |
| 
 | |
| class PinMap
 | |
| {
 | |
|   friend class LoRaRadio;
 | |
|   public:
 | |
|     PinMap(u1_t nss, u1_t rxtx, u1_t rst, const u1_t dio[3]) : _nss(nss), _rxtx(rxtx), _rst(rst)
 | |
|     {
 | |
|       _dio[0] = dio[0];
 | |
|       _dio[1] = dio[1];
 | |
|       _dio[2] = dio[2];
 | |
|     }
 | |
|   protected:
 | |
|   private:
 | |
|     u1_t _nss, _rxtx, _rst, _dio[3];
 | |
| };
 | |
| 
 | |
| class LoRaRadio
 | |
| {
 | |
|   public:
 | |
|     LoRaRadio(PinMap pinMap, dr_t dataRate = DR_SF7, s1_t txPower = 23);
 | |
|     
 | |
|     void init();
 | |
|     void setTTNSession(u4_t channelId, devaddr_t deviceAddress, xref2u1_t networkSystemKey, xref2u1_t applicationSystemKey, bit_t linkCheckMode = 0);
 | |
|     void setRadioEUChannels();
 | |
|     void setMCUClockError(u2_t percent = 30);
 | |
|     void send(u1_t port, uint8_t *data, uint8_t length, u1_t confirmed = false);
 | |
|     void run();
 | |
|     void setDownlinkHandler(void (*funcP)(u1_t, u1_t, u1_t*));
 | |
|     void disableEUChannel(u1_t channel);
 | |
|     void disableAllEUChannelsBut(u1_t channel);
 | |
| 
 | |
|     //Function pointers used to interact with events
 | |
|     //Parameters : dataLen, dataBeg, dataBuffer
 | |
|     static void (*downlinkHandler)(u1_t, u1_t, u1_t*);
 | |
|   protected:
 | |
|   private:
 | |
|     dr_t _dataRate;
 | |
|     s1_t _txPower;
 | |
|     PinMap _pinMap;
 | |
| };
 | |
| 
 | |
| #endif //LORARADIO_H
 |