- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to add custom advertisement data in hello_client.
This is the code I am adding in void hello_client_create(void) function (copied from hello_sensor):
// Read value of the service from GATT DB.
bleprofile_ReadHandle(HANDLE_HELLO_SENSOR_SERVICE_UUID, &db_pdu);
ble_tracen((char *)db_pdu.pdu, db_pdu.len);
if (db_pdu.len != 16)
{
ble_trace1("bad service UUID len: %d\n", db_pdu.len);
}
else
{
// total length should be less than 31 bytes
BLE_ADV_FIELD adv[3];
// flags
adv[0].len = 1 + 1;
adv[0].val = ADV_FLAGS;
adv[0].data[0] = LE_LIMITED_DISCOVERABLE | BR_EDR_NOT_SUPPORTED;
adv[1].len = 16 + 1;
adv[1].val = ADV_SERVICE_UUID128_COMP;
memcpy(adv[1].data, db_pdu.pdu, 16);
// name
adv[2].len = strlen(bleprofile_p_cfg->local_name) + 1;
adv[2].val = ADV_LOCAL_NAME_COMP;
memcpy(adv[2].data, bleprofile_p_cfg->local_name, adv[2].len - 1);
bleprofile_GenerateADVData(adv, 3);
}
At this point discoverable is turned on with:
// need to do adverts to enable slave connections
bleprofile_Discoverable(HIGH_UNDIRECTED_DISCOVERABLE, NULL);
What I noticed is that device is not discoverable for the first 30 seconds (high_undirect_adv_duration) until bleprofile_GetDiscoverable() reports:
LOW_UNDIRECTED_DISCOVERABLE
Can you tell me why it cannot start from HIGH_UNDIRECTED_DISCOVERABLE ?
I am attaching modified hello_client.
Solved! Go to Solution.
- Labels:
-
SDK 2.X
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you invoking both bleprofile_Init() and blecen_Create()? If you are, then remove the call to bleprofile_Init().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I took a quick glance of the above. I thought you missed a line:
blecm_setTxPowerInADV(0);
bleprofile_Discoverable(HIGH_UNDIRECTED_DISCOVERABLE, NULL);
Try it out...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I added:
blecm_setTxPowerInADV(0);
but that did not change anything
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I think you missed the line
// total length should be less than 31 bytes
Please try hell instead of hello client.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I copied this section as is from hello_sensor.
It works in hello_sensor.
Why doesn't it work in hello_client ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you invoking both bleprofile_Init() and blecen_Create()? If you are, then remove the call to bleprofile_Init().
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That was it.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I believe that calling both function 'bleprofile_Init' and 'blecen_Create' is originated in the sample hello_client.c from WICED Smart SDK.
Would you comment that which one is supposed to be removed? 'bleprofile_Init' or 'blecen_Create'?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In 2.2 version of the hello_client ble profile calls are commented out
// this is done by blecen
// bleprofile_Init(bleprofile_p_cfg);
// bleprofile_GPIOInit(bleprofile_gpio_p_cfg);