examples/witenergy/main.c
static bool __is_oort_service_present(const ble_gap_evt_adv_report_t *p_adv_report) {
  uint8_t service_id[16] = OORT_BASE_UUID;
  uint32_t index         = 0;
  uint8_t *p_data        = (uint8_t *)p_adv_report->data;

  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_128BIT_SERVICE_UUID_MORE_AVAILABLE ||
         field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE) &&
        (field_length - 1 == 16 &&
         memcmp(service_id, &p_data[index + 2], 16) == 0)) {
      return true;
    }
    index += field_length + 1;
  }
  return false;
}
// Check that the gateway is advertising the correct service UUID.
Check that the gateway is advertising the correct service UUID.
Check that the gateway is advertising the correct service UUID .
static bool __is_oort_service_present(const ble_gap_evt_adv_report_t *p_adv_report) {
  uint8_t service_id[16] = OORT_BASE_UUID;
  uint32_t index         = 0;
  uint8_t *p_data        = (uint8_t *)p_adv_report->data;
  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_128BIT_SERVICE_UUID_MORE_AVAILABLE ||
         field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE) &&
        (field_length - 1 == 16 &&
         memcmp(service_id, &p_data[index + 2], 16) == 0)) {
      return true;
    }
    index += field_length + 1;
  }
  return false;
}
static bool __is_oort_service_present ( const ble_gap_evt_adv_report_t * p_adv_report ) { uint8_t service_id [ 16 ] = OORT_BASE_UUID ; uint32_t index = 0 ; uint8_t * p_data = ( uint8_t * ) p_adv_report -> data ; 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_128BIT_SERVICE_UUID_MORE_AVAILABLE || field_type == BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE ) && ( field_length - 1 == 16 && memcmp ( service_id , & p_data [ index + 2 ] , 16 ) == 0 ) ) { return true ; } index += field_length + 1 ; } return false ; }
Check that the gateway is advertising the correct service UUID.
Check that the gateway is advertising the correct service UUID .