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.
Diff: main.cpp
- Revision:
- 8:beb6c399490a
- Parent:
- 7:2df2c6e8c0df
- Child:
- 9:9a4c81493a3d
--- a/main.cpp Thu Jan 14 22:20:38 2016 +0000 +++ b/main.cpp Fri Jan 15 20:59:51 2016 +0000 @@ -13,6 +13,25 @@ Serial pc(USBTX, USBRX); // tx, rx +void handle_pc_input(); +void handle_cdc_input(); +void handle_bt_input(); + +int main() { + + printf("Petters BT CDC-emulator\r\n"); + printf("Initializing\r\n"); + cdc.init(); + rn52.init(); + printf("Starting loop\r\n"); + while(1) { + handle_pc_input(); + handle_cdc_input(); + handle_bt_input(); + } +} + + void handle_pc_input() { //Debug connection to PC if(pc.readable()) { @@ -32,11 +51,11 @@ break; case 'q': printf("getting status\r\n"); - rn52.get(RN52_GETSTATUS, &res); + rn52.get_status(&res); printf("%s\r\n", res.response); break; case 't': - rn52.get(RN52_CALLER_ID, &res); + rn52.get_caller_id(&res); printf("%s\r\n", res.response); break; } @@ -88,6 +107,7 @@ break; case RN52_TRACK_CHANGE_EVENT: cdc.reset_elapsed_time(); + /* printf("Track change event\r\n"); printf("title: %s\r\n", res.title); printf("artist: %s\r\n", res.artist); @@ -96,10 +116,11 @@ printf("duration: %i\r\n", res.duration); printf("track_count: %i\r\n", res.track_count); printf("track_number: %i\r\n", res.track_number); - //cdc.display(res.title); - //cdc.set_track((char)res.track_number); + */ + cdc.display(res.title); + cdc.set_track((char)res.track_number); break; - case RN52_NO_EVENT: //no specific event occured, check connection status + case RN52_OTHER_EVENT: //no specific event occured, check connection status switch(res.connection) { case RN52_CONNECTABLE_DISCOVERABLE: printf("Waiting for connection\r\n"); @@ -121,17 +142,4 @@ } } } -} - -int main() { - printf("Petters BT CDC-emulator\r\n"); - printf("Initializing\r\n"); - cdc.init(); - rn52.init(); - printf("Starting loop\r\n"); - while(1) { - handle_pc_input(); - handle_cdc_input(); - handle_bt_input(); - } } \ No newline at end of file