This is example code that can get you started with building your own IR vision robot that communicates over LoRa
Dependencies: Adafruit-MotorShield Adafruit-PWM-Servo-Driver Adafruit_GFX BufferedSerial MAX17055_EZconfig NEO-6m-GPS SX1276GenericLib USBDeviceHT max32630fthr max77650_charger_sample
Fork of MAX326xxFTHR_LoRa_Example_test by
global_buffers.h
- Committer:
- dev_alexander
- Date:
- 2018-07-18
- Revision:
- 24:e8d03912f303
- Parent:
- 23:f74a50977593
- Child:
- 25:1a031add188a
File content as of revision 24:e8d03912f303:
/** Description: * This File is responsible for defining the buffers that will be used in * various areas of the program. The buffers that are defined here will be * refferenced in the main.cpp and will be filled with data in one of two ways: * * 1. The buffers will be filled with data upon receiving a successful payload * transmission over LoRa. In GenericPingPong.cpp, the function OnRxDone() * will call the function fillGlobalBufsWithPayload() that is responsible for * filling the appropriate buffers with the payload data that was received * by either the master or slave device by the other device that sent it. * * 2. The buffers will be used to fill up a payload buffer that will be sent * over LoRa by either the master or slave device to the receiving device. * The function fillPayloadWithGlobalBufs() will use the global buffers that * are filled with data for various sensors in the main.cpp to construct a * payload to deliver to the other device when SX1276PingPong() is called * in file GenericPingPong.cpp. * */ #ifndef __GLOBAL_BUFFERS_H__ #define __GLOBAL_BUFFERS_H__ /*************************************************************************** * Indexes for which byte specific data begins at in the payload buffer **************************************************************************/ /* size of data in bytes that is acquired by the master device */ const uint8_t size_of_ble = 2; /* size of data in bytes that is acquired by the slave device */ const uint8_t size_of_grid_eye = 128; const uint8_t size_of_gps = 20; const uint8_t size_of_MAX17055 = 5; const uint8_t size_of_MAX77650 = 5; const uint16_t PAYLOAD_BUFFER_SIZE_MASTER_TO_SLAVE = size_of_ble; const uint16_t PAYLOAD_BUFFER_SIZE_SLAVE_TO_MASTER = size_of_grid_eye + size_of_gps + size_of_MAX17055 + size_of_MAX77650; #if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway /* These are indexs used to create the payload buffer to send to Slave */ const uint8_t tx_idx_ble = 0; // 1st buf in tx payload (begins at byte 0) /* These are indexs used to deconstruct received payload buffer sent by the Slave */ const uint8_t rx_idx_grid_eye = 0; // 1st buf in rx payload (begins at byte 0) const uint8_t rx_idx_gps = rx_idx_grid_eye + size_of_grid_eye; // 2nd buf in rx payload const uint8_t rx_idx_MAX17055 = rx_idx_gps + size_of_gps; // 3rd buf in rx payload const uint8_t rx_idx_MAX77650 = rx_idx_MAX17055 + size_of_MAX17055; // 4th buf in rx payload #elif defined(TARGET_MAX32620FTHR) // Client Device: LoRa Controlled Robot /* These are indexs used to create the payload buffer to send to Master */ const uint8_t tx_idx_grid_eye = 0; // 1st buf in tx payload (begins at byte 0) const uint8_t tx_idx_gps = tx_idx_grid_eye + size_of_grid_eye; // 2nd buf in tx payload const uint8_t tx_idx_MAX17055 = tx_idx_gps + size_of_gps; // 3rd buf in tx payload const uint8_t tx_idx_MAX77650 = tx_idx_MAX17055 + size_of_MAX17055; // 4th buf in tx payload /* These are indexs used to deconstruct received payload buffer sent by the Master */ const uint8_t rx_idx_ble = 0; // 1st buf in rx payload (begins at byte 0) #endif /*************************************************************************** * Grid Eye Sensor Data Buffers **************************************************************************/ #if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway static char curr_raw_frame_data_from_slave[payload_grid_eye_size]; static char prev_raw_frame_data_from_slave[payload_grid_eye_size]; static int16_t conv_frame_data_from_slave[64]; #elif defined(TARGET_MAX32620FTHR) // Client Device: LoRa Controlled Robot static char curr_raw_frame_data_to_master[128]; #endif /*************************************************************************** * BLE Data Buffers **************************************************************************/ #if defined(TARGET_MAX32630FTHR) // Master Device: BLE-to-LoRa Gateway static char curr_ble_data_to_slave[2]; #elif defined(TARGET_MAX32620FTHR) // Slave Device: LoRa Controlled Robot static char curr_ble_data_from_master[2]; static char prev_ble_data_from_master[2]; #endif /** * @brief This function constructs a payload buffer that is used in transmitting data in a LoRa Message */ int fillPayloadWithGlobalBufs(); /** * @brief This function deconstructs a payload buffer that contains data from a received LoRa Message */ int fillGlobalBufsWithPayload(); #endif // __GLOBAL_BUFFERS_H__