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.
Revision 4:6f32ed1480a4, committed 2020-01-08
- Comitter:
- MwadimeMakokha
- Date:
- Wed Jan 08 11:31:58 2020 +0000
- Parent:
- 3:936c6d909891
- Commit message:
- Add comments
Changed in this revision
BT.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/BT.cpp Wed Jan 08 11:23:14 2020 +0000 +++ b/BT.cpp Wed Jan 08 11:31:58 2020 +0000 @@ -10,12 +10,19 @@ power_bt_device(1); bt_unpair_device(); } +/* +@brief Get the bluetooth status -> The modem response contains the status +*/ void BT::get_bt_status(){ - send_bt_cmd("AT+BTSTATUS?"); + send_bt_cmd("AT+BTSTATUS?"); get_response(1000,true); DEBUG_PRINTLN("%s",modem_response); } +/* +@brief power the bt funtionality on/off depending on the params passed +@params bool on/off -> determines if bt powered on or off +*/ void BT::power_bt_device(bool on){ if(on)send_bt_cmd("AT+BTPOWER=1"); else send_bt_cmd("AT+BTPOWER=0"); @@ -23,6 +30,11 @@ DEBUG_PRINTLN("%s",modem_response); } +/* +@brief scan for the devices for the time passed in the params and gets the phone id from the mac_address +@params waiting time for scanning +@retval phone id +*/ char BT::bt_scan(uint32_t timeout){ char id; if(timeout>60000){ @@ -39,8 +51,12 @@ return id; } +/* +@brief pair with device of the id given +@params id of the phone to be paired +*/ void BT::bt_pair_device(char id){ - DEBUG_PRINTLN("iD returned"); + DEBUG_PRINTLN("ID returned"); modemSerial->printf("AT+BTPAIR=0,%c\n\r",id); get_response(5000,true); DEBUG_PRINTLN("%s",modem_response); @@ -54,10 +70,20 @@ } } +/* +@brief provide mac address of the bt phone +@retval mac_address +*/ char* BT::get_phone_mac_addr(){ + //TODO: Get mac address from MQTT event return mac_addr_1; +} - } +/* +@brief get the device bt id +@params mac_address of the device +@retval device bt id +*/ char BT::get_phone_id(char* addr){ char id=0; bool id_found=false; @@ -83,6 +109,10 @@ return id_found?id:'0'; } +/* +@brief get the passkey during pairing +@retval the pairing passkeys +*/ char* BT::get_phone_passkey(){ int arr_index = 0; char* passkey=new char[7]; @@ -109,22 +139,35 @@ return "error"; } +/* +@brief unpair bt device +*/ void BT::bt_unpair_device(){ send_bt_cmd("AT+BTUNPAIR=0"); get_response(1000,false); } +/* +@brief connect to bt device +*/ void BT::bt_connect_device(char id){ modemSerial->printf("AT+BTCONNECT=%c,10\n\r",id); get_response(2000,true); DEBUG_PRINTLN("%s",modem_response); } +/* +@brief disconnect bt device +*/ void BT::bt_disconnect_device(char id){ modemSerial->printf("AT+BTDISCONN=%c",id); get_response(2000,true); DEBUG_PRINTLN("%s",modem_response); } + +/* +@brief gets the bt device available profiles +*/ void BT::bt_get_profile_id(char id){ modemSerial->printf("AT+BTGETPROF=%c\n\r",id); get_response(2000,true);