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: WirelessInterface mbed
main.cpp@0:6b892e818f10, 2016-04-24 (annotated)
- Committer:
- gboggs3
- Date:
- Sun Apr 24 18:24:36 2016 +0000
- Revision:
- 0:6b892e818f10
- Child:
- 1:c7cfaf8c38f2
Code to test the Wireless Interface library.;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| gboggs3 | 0:6b892e818f10 | 1 | #include "mbed.h" |
| gboggs3 | 0:6b892e818f10 | 2 | #include "WirelessInterface.h" |
| gboggs3 | 0:6b892e818f10 | 3 | //Wireless Interface contains include files for the Huzzah and BT Friend |
| gboggs3 | 0:6b892e818f10 | 4 | #include <string> |
| gboggs3 | 0:6b892e818f10 | 5 | |
| gboggs3 | 0:6b892e818f10 | 6 | //Debug serial port |
| gboggs3 | 0:6b892e818f10 | 7 | RawSerial pc(USBTX, USBRX); |
| gboggs3 | 0:6b892e818f10 | 8 | |
| gboggs3 | 0:6b892e818f10 | 9 | WirelessInterface cmd(p28,p27,p26,pc); //Comment this out to manually configure each device individually |
| gboggs3 | 0:6b892e818f10 | 10 | //Huzzah cmd(p28,p27,p26,pc); |
| gboggs3 | 0:6b892e818f10 | 11 | //BTFriend cmd(p28,p27,p26,pc); |
| gboggs3 | 0:6b892e818f10 | 12 | DigitalOut sel(p22); |
| gboggs3 | 0:6b892e818f10 | 13 | InterruptIn pb(p18); |
| gboggs3 | 0:6b892e818f10 | 14 | |
| gboggs3 | 0:6b892e818f10 | 15 | //Interrupt function to change the selected device to communicate with |
| gboggs3 | 0:6b892e818f10 | 16 | void changeDevice() |
| gboggs3 | 0:6b892e818f10 | 17 | { |
| gboggs3 | 0:6b892e818f10 | 18 | sel = !sel; |
| gboggs3 | 0:6b892e818f10 | 19 | |
| gboggs3 | 0:6b892e818f10 | 20 | char selDev[256]; |
| gboggs3 | 0:6b892e818f10 | 21 | if(!sel) |
| gboggs3 | 0:6b892e818f10 | 22 | sprintf(selDev, "Huzzah WiFi Module"); |
| gboggs3 | 0:6b892e818f10 | 23 | else |
| gboggs3 | 0:6b892e818f10 | 24 | sprintf(selDev, "Bluetooth Module"); |
| gboggs3 | 0:6b892e818f10 | 25 | |
| gboggs3 | 0:6b892e818f10 | 26 | pc.printf("Communicating with: '%s'\r\n", selDev); |
| gboggs3 | 0:6b892e818f10 | 27 | wait(1); //Debounce |
| gboggs3 | 0:6b892e818f10 | 28 | } |
| gboggs3 | 0:6b892e818f10 | 29 | |
| gboggs3 | 0:6b892e818f10 | 30 | int main() |
| gboggs3 | 0:6b892e818f10 | 31 | { |
| gboggs3 | 0:6b892e818f10 | 32 | sel = 0; //0 = WiFi, 1 = Bluetooth |
| gboggs3 | 0:6b892e818f10 | 33 | |
| gboggs3 | 0:6b892e818f10 | 34 | /* An external interrupt can be setup to change the sel pin during runtime */ |
| gboggs3 | 0:6b892e818f10 | 35 | pb.rise(&changeDevice); |
| gboggs3 | 0:6b892e818f10 | 36 | |
| gboggs3 | 0:6b892e818f10 | 37 | while(1) { |
| gboggs3 | 0:6b892e818f10 | 38 | sleep(); |
| gboggs3 | 0:6b892e818f10 | 39 | } |
| gboggs3 | 0:6b892e818f10 | 40 | } |