Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: MbedJSONValue SX127x sx12xx_hal
Diff: main.cpp
- Revision:
- 6:83bedc32acaf
- Parent:
- 5:a8b4e0857e8b
- Child:
- 7:803a185d7021
--- a/main.cpp Tue Sep 24 21:10:25 2019 +0000
+++ b/main.cpp Tue Sep 24 21:13:28 2019 +0000
@@ -74,91 +74,6 @@
};
/**
-* Function for printing the contents of the SX127x transmit buffer
-*/
-void print_radio_tx_buffer(uint8_t len)
-{
- printf("Tx Buffer = ");
- for(int i=0; i<len; i++)
- {
- printf("%d ", Radio::radio.tx_buf[i]);
- }
- printf("\r\n\n");
-}
-
-/**
-* Function for adding bytes to the circular buffer for the message.
-*/
-void msg_append_bytes(uint8_t data[], uint8_t len)
-{
- for(int i=0; i < len; i++)
- {
- if(!msg.full())
- {
- msg.push(data[i]);
- }
- else{
- // If buffer is full, contents will be over-written
- // TODO: Handle this error case
- printf("buffer is full\n");
- }
- }
-}
-
-/**
-* Function for adding a string to the circular buffer for the message
-*/
-void msg_append_string(string str, uint8_t len)
-{
- msg_append_bytes(reinterpret_cast<uint8_t*>(&str[0]), len);
-}
-
-/**
-* Function for sending the message.
-*
-* @note This function copies the contents of the circular buffer to the transmit
-* buffer.
-*/
-void msg_send()
-{
- uint8_t len = 0;
- while(!msg.empty())
- {
- // Pop data from the circular buffer to Radio tx_buf
- msg.pop(Radio::radio.tx_buf[len]);
-
- // Track the size of the tx_buf
- len++;
- }
- print_radio_tx_buffer(len);
- txDone = false;
- Radio::Send(len, 0, 0, 0); // begin transmission of payload
-}
-
-/**
-* Interrupt handler for the User button.
-*/
-void button_send()
-{
- // Create an array to hold byte data
- uint8_t data[] = {seq};
-
- // Append the byte array to the message
- msg_append_bytes(data, sizeof(data)/sizeof(data[0]));
-
- // Append a new value to the message
- data[0] = seq+1;
- msg_append_bytes(data, sizeof(data)/sizeof(data[0]));
-
- // Append a string to the message
- string myString = "Hello World!";
- msg_append_string(myString, myString.length());
- msg_send();
-
- seq+=2; // change payload (increment sequence number)
-}
-
-/**
* Interrupt Handler for the User button.
*/
void button_send_json()
@@ -206,7 +121,6 @@
int main()
{
printf("\r\nreset-tx \n");
-// button.fall(&button_send);
button.fall(&button_send_json);
radio_init();