This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF51822 S110 BLE, use Advertising packet send skin temperature to iphone every 30min

The test code:

int main(void) {

sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_RC_250_PPM_250MS_CALIBRATION, softdevice_assertion_handle);

temp_init();
unsigned int aaa=temp();
unsigned char advdata[] = {0x9,0x09,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38, 0x02,0x01,0x04, 0x03,0xff,0xff,0x34, 0x03,0x03,0x09,0x18};	// #define BLE_UUID_HEALTH_THERMOMETER_SERVICE  0x1809	// Health Thermometer service UUID.

advdata[15] = aaa>>8; advdata[16] = aaa;
sd_ble_gap_adv_data_set((unsigned char *)&advdata[0], 21, 0, 0);

static ble_gap_adv_params_t m_adv_params;
m_adv_params.type        = BLE_GAP_ADV_TYPE_ADV_NONCONN_IND;
m_adv_params.p_peer_addr = 0;	// Undirected advertisement
m_adv_params.fp          = BLE_GAP_ADV_FP_ANY;
m_adv_params.p_whitelist = 0;
m_adv_params.interval    = 480;	// The advertising interval (in units of 0.625 ms. 100ms/0.625ms=160). when advertising non-connectable, interval must be at least 100 ms.
m_adv_params.timeout     = 1;	// The advertising timeout in units of seconds.

advdata[0] = sd_ble_gap_adv_start(&m_adv_params);

{ for(unsigned int i=0;i<90000000;i++) { __ASM { NOP } } } // delay 30s, for test.
NVIC_SystemReset();
for (;;) { }

}

I'll optimize the code to Low power consume next.

The problem now is that Iphone app can not get data in "background mode" as refer in : developer.apple.com/.../CBCentralManager.html

"Apps that have specified the bluetooth-central background mode are allowed to scan while in the background. That said, they must explicitly scan for one or more services by specifying them in the serviceUUIDs parameter. The CBCentralManagerOptionShowPowerAlertKey scan option is ignored while scanning in the background."

means service UUID parameter is needed, but iphone APP give the uuid like: UUID= "187356E0-7327-22BA-DC77-BFA63240BBB0" and the UUID 0x1809(BLE_UUID_HEALTH_THERMOMETER_SERVICE) seems not work.

Iphone app like this: image description

When iphone screen black, the advertising packet data losed. I don't know how UUID= "187356E0-7327-22BA-DC77-BFA63240BBB0" work out.

I want use advertising packet send the temperature data, just 4byte, every 30min or 60min, one 100mAh battery one year.

Is it any example code for ios app get the adv packet data?

Best regards

BTW: wireshark sniffer picture:

image description

Parents
  • Hi Sai, Thanks for the link: developer.xamarin.com/.../

    "The simplest way to perform backgrounding on iOS is to break your backgrounding requirements into tasks, and run the tasks in the background. Tasks are under a strict time limit, and typically get about 600 seconds (10 minutes) of processing time after an application has moved to the background on iOS 6, and less than 10 minutes on iOS 7."

    10min...

    For BLE peripheral , most time is sleeping, every 30min or 60min wakeup and send packet out. Can the ios APP get the packet as wireshark do ?

    Android phone can do it as I knows.

  • Have a look at this link about support background mode operations in an iPhone app. - www.devfright.com/.../

    I could be wrong here but it looks like your question relates to iOS rather than BLE so you are probably better off asking it on StackOverflow. As long as your BLE chip wakes up every 30 minutes and advertises a packet, the Nordic dev forum isn't the correct place to ask for iOS app assistance. If I misunderstood your problem and it IS, in fact, BLE related, please carry on :).

Reply
  • Have a look at this link about support background mode operations in an iPhone app. - www.devfright.com/.../

    I could be wrong here but it looks like your question relates to iOS rather than BLE so you are probably better off asking it on StackOverflow. As long as your BLE chip wakes up every 30 minutes and advertises a packet, the Nordic dev forum isn't the correct place to ask for iOS app assistance. If I misunderstood your problem and it IS, in fact, BLE related, please carry on :).

Children
No Data
Related