![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Wireless interface using LoRa technology
Dependencies: AlohaTransceiver RingBuffer SX1276Lib SerialInterfaceProtocol mbed L3PDU
Diff: main.cpp
- Revision:
- 6:19457108c899
- Parent:
- 5:445f35444a6a
- Child:
- 8:332099ece6e9
--- a/main.cpp Sat Jul 23 07:42:58 2016 +0000 +++ b/main.cpp Wed Jul 27 03:21:37 2016 +0000 @@ -52,6 +52,31 @@ return 0; } +int sendMessage(uint8_t *payload, uint8_t payload_length, uint8_t *response, uint8_t *response_length) +{ + static uint8_t seqid = 0; + + // prepare for the frame + txFrame.setType(AlohaFrame::Aloha_Data); + txFrame.setPayloadLength(0x0); + txFrame.setSourceAddress(0x1); + txFrame.setDestinationAddress(0x2); + txFrame.setFullMessageFlag(0x1); + txFrame.setSequenceID(seqid); + txFrame.generateCrc(); + + + uint8_t buffer[20]; + memset(buffer, 0x0, sizeof(buffer)); + txFrame.serialize(buffer); + + aloha.send(buffer, 20); + + seqid += 1; + + return 0; +} + void AlohaDataEcho(AlohaFrame *frame) { // get rssi and snr @@ -97,12 +122,15 @@ int main() { // initialize radio module aloha.boardInit(); + aloha.updateSettings(); + aloha.enable(); // attach serial interrupt handler pc.attach(&serialInterruptHandler); // register callback functions for SIP SIP.registerCommand(0x00, toggleChecksum); + SIP.registerCommand(0x01, sendMessage); // register callback functions for aloha transceiver aloha.registerType(AlohaFrame::Aloha_Data, AlohaDataEcho);