Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions firmware/application/lib/bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
* Author: Ted Salmon <tass2001@gmail.com>
* Description:
* Implementation of the abstract Bluetooth Module API
* History:
* Feb 2024 (Matt C) - Added phone book access (currently for BM83 only)
*/
#include "bt.h"
#include "locale.h"
#include "bt/bt_bm83_pbap.h"

/**
* BTInit()
Expand Down Expand Up @@ -459,6 +462,63 @@ void BTCommandToggleVoiceRecognition(BT_t *bt)
}
}

/**
* BTGetCommandReqPhonebookFrom
* @param bt - pointer to the bluetooth module
* @param offset - index to start
*
* Requests a phone book entries starting from the provided offset
*/
void BTCommandReqPhonebookFrom(BT_t *bt, uint8_t offset) {
if (bt->type == BT_BTM_TYPE_BM83) {
// TODO: Manage paging in the menu
BM83CommandPBAPPullPhoneBook(bt, PBAP_TYPE_PHONEBOOK, offset);
} else {
LogDebug(LOG_SOURCE_BT, "Get Phonebook - not implemented for BC127");
}
}

/**
* BTCommandReqPhonebook()
* @param bt - pointer to the module object
*
* Requests the first entries from the phone book.
* A convenience function for BTCommandReqPhonebookFrom with 0 offset
*/
void BTCommandReqPhonebook(BT_t *bt)
{
BTCommandReqPhonebookFrom(bt, 0);
}
/**
* BTCommandReqFavorites()
* @param bt - A pointer to the bluetooth module object
*
* Requests the "Top-8" from phone favorites.
*/
void BTCommandReqFavorites(BT_t *bt)
{
if (bt->type == BT_BTM_TYPE_BM83) {
// TODO: Manage paging in the menu
BM83CommandPBAPPullPhoneBook(bt, PBAP_TYPE_FAVORITE_CONTACTS, 0);
} else {
LogDebug(LOG_SOURCE_BT, "Get Favorites - not implemented for BC127");
}
}
/**
* BTCommandReqRecent()
* @param bt - A pointer to the bluetooth module object
*
* Requests the combined call history from phone
*/
void BTCommandReqRecent(BT_t *bt)
{
if (bt->type == BT_BTM_TYPE_BM83) {
BM83CommandPBAPPullPhoneBook(bt, PBAP_TYPE_COMBINED_CALL_HISTORY, 0);
} else {
LogDebug(LOG_SOURCE_BT, "Get Call History - not implemented for BC127");
}
}

/**
* BTHasActiveMacId()
* Description:
Expand Down
4 changes: 4 additions & 0 deletions firmware/application/lib/bt.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ void BTCommandSetDiscoverable(BT_t *, unsigned char);
void BTCommandToggleVoiceRecognition(BT_t *);
uint8_t BTHasActiveMacId(BT_t *);
void BTProcess(BT_t *);
void BTCommandReqPhonebookFrom(BT_t *, uint8_t);
void BTCommandReqPhonebook(BT_t *);
void BTCommandReqFavorites(BT_t *);
void BTCommandReqRecent(BT_t *);
#endif /* BT_H */
7 changes: 7 additions & 0 deletions firmware/application/lib/bt/bt_bm83.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@
* Author: Ted Salmon <tass2001@gmail.com>
* Description:
* Implementation of the Microchip BM83 Bluetooth UART API
* Revision History:
* Feb 2024 (Matt C) - Forward PBAP events to handler in bt_phonebook.c
*/
#include "bt_bm83.h"
#include "bt_bm83_pbap.h"
#include "../locale.h"

int8_t BTBM83MicGainTable[] = {
Expand Down Expand Up @@ -1331,6 +1334,10 @@ void BM83Process(BT_t *bt)
if (event == BM83_EVT_REPORT_TYPE_CODEC) {
BM83ProcessEventReportTypeCodec(bt, eventData, dataLength);
}
/* Phone Book events */
if (event == BM83_EVT_PBAPC_EVENT) {
BM83ProcessEventPhoneBook(bt, eventData, dataLength);
}
}
}
UARTReportErrors(&bt->uart);
Expand Down
1 change: 0 additions & 1 deletion firmware/application/lib/bt/bt_bm83.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,4 @@ void BM83ProcessDataGetAllAttributes(BT_t *, uint8_t *, uint8_t, uint16_t);
/* RX / TX */
void BM83Process(BT_t *);
void BM83SendCommand(BT_t *, uint8_t *, size_t);

#endif /* BM83_H */
Loading