Skip to content

Commit

Permalink
Version 5.
Browse files Browse the repository at this point in the history
  • Loading branch information
cody82 committed Jan 19, 2017
1 parent 8e0e6d4 commit 74327c3
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 59 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
all:
cd car_app/pca10028/s130/armgcc && make && make genpkg
cd car_remote/pca10028/s130/armgcc && make

remote:
cd car_remote/pca10028/s130/armgcc && make

app:
cd car_app/pca10028/s130/armgcc && make && make genpkg

3 changes: 3 additions & 0 deletions car_app/main_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,9 @@ static void ble_start()

void main_ble(void)
{
car_uuid.uuid128[12] = (uint8_t)(BLE_UUID_CAR_SERVICE & 0xFF);
car_uuid.uuid128[13] = (uint8_t)((BLE_UUID_CAR_SERVICE>>8) & 0xFF);

timers_init();

CarInit();
Expand Down
2 changes: 1 addition & 1 deletion car_app/pca10028/s130/armgcc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,4 @@ flash_softdevice:
nrfjprog --reset -f nrf51

genpkg:
nrfutil pkg generate --debug-mode --application _build/nrf51422_xxac.hex --application-version 4 --hw-version 1 --sd-req 0x87 --key-file ../../../ota-key.pem car-app-ota-v4.zip
nrfutil pkg generate --debug-mode --application _build/nrf51422_xxac.hex --application-version 5 --hw-version 1 --sd-req 0x87 --key-file ../../../ota-key.pem car-app-ota-v5.zip
69 changes: 11 additions & 58 deletions car_remote/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ static const ble_uuid_t m_car_uuid =
.type = CAR_SERVICE_UUID_TYPE
};

ble_uuid128_t car_uuid = CAR_BASE_UUID;

/**@brief Function for asserts in the SoftDevice.
*
* @details This function will be called in case of an assert in the SoftDevice.
Expand Down Expand Up @@ -221,79 +223,28 @@ static void ble_car_c_evt_handler(ble_car_c_t * p_ble_car_c, const ble_car_c_evt
*
* @retval true if the UUID is present in the advertisement report. Otherwise false
*/
static bool is_uuid_present(const ble_uuid_t *p_target_uuid,
static bool is_uuid_present(const ble_uuid128_t *p_target_uuid,
const ble_gap_evt_adv_report_t *p_adv_report)
{
return true;
/*uint32_t err_code;
uint32_t index = 0;
uint8_t *p_data = (uint8_t *)p_adv_report->data;
ble_uuid_t extracted_uuid;

while (index < p_adv_report->dlen)
{
uint8_t field_length = p_data[index];
uint8_t field_type = p_data[index + 1];

if ( (field_type == BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE)
|| (field_type == BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE)
)
{
for (uint32_t u_index = 0; u_index < (field_length / UUID16_SIZE); u_index++)
{
err_code = sd_ble_uuid_decode( UUID16_SIZE,
&p_data[u_index * UUID16_SIZE + index + 2],
&extracted_uuid);
if (err_code == NRF_SUCCESS)
{
if ((extracted_uuid.uuid == p_target_uuid->uuid)
&& (extracted_uuid.type == p_target_uuid->type))
{
return true;
}
}
}
}
else if ( (field_type == BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE)
|| (field_type == BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE)
)
{
for (uint32_t u_index = 0; u_index < (field_length / UUID32_SIZE); u_index++)
{
err_code = sd_ble_uuid_decode(UUID16_SIZE,
&p_data[u_index * UUID32_SIZE + index + 2],
&extracted_uuid);
if (err_code == NRF_SUCCESS)
{
if ((extracted_uuid.uuid == p_target_uuid->uuid)
&& (extracted_uuid.type == p_target_uuid->type))
{
return true;
}
}
}
}
else if ( (field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE)
if ( (field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE)
|| (field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE)
)
{
err_code = sd_ble_uuid_decode(UUID128_SIZE,
&p_data[index + 2],
&extracted_uuid);
if (err_code == NRF_SUCCESS)
{
if ((extracted_uuid.uuid == p_target_uuid->uuid)
&& (extracted_uuid.type == p_target_uuid->type))
{
return true;
}
}
if(memcmp(&p_data[index + 2], p_target_uuid, sizeof(ble_uuid128_t)) == 0)
return true;
}
index += field_length + 1;
}
return false;*/

return false;
}

/**@brief Function for handling the Application's BLE Stack events.
Expand All @@ -311,7 +262,7 @@ static void on_ble_evt(ble_evt_t * p_ble_evt)
{
const ble_gap_evt_adv_report_t * p_adv_report = &p_gap_evt->params.adv_report;

if (is_uuid_present(&m_car_uuid, p_adv_report))
if (is_uuid_present(&car_uuid, p_adv_report))
{

err_code = sd_ble_gap_connect(&p_adv_report->peer_addr,
Expand Down Expand Up @@ -487,6 +438,8 @@ static void power_manage(void)

int main(void)
{
car_uuid.uuid128[12] = (uint8_t)(BLE_UUID_CAR_SERVICE & 0xFF);
car_uuid.uuid128[13] = (uint8_t)((BLE_UUID_CAR_SERVICE>>8) & 0xFF);
//APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);

buttons_leds_init();
Expand Down

0 comments on commit 74327c3

Please sign in to comment.