- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

how to get a random number with the sdk?

just a random number,the get opreat does not affact orther!

Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

I just did a search on Google and there are a number of SW methods of generating a pseudo-random number that you can implement in the app. If you need a seed for your random number generator, you may use the Bluetooth clock as the first seed value:

/// This function returns the current native Bluetooth clock; this

/// counter is 28 bits, and ticks every 312.5 us and is adjusted for

/// drift through sleep, etc. To compute differences and times elapsed,

/// use bleapputils_diffNativeBtClks() or bleapputils_BtClksSince().

/// \return the counter value.

UINT32 bleapputils_currentNativeBtClk(void);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

With SDK 2.0, use:

/// Provides any number of random bit from the HW random bit generator.

/// \param buffer pointer to a buffer that can hold the random bits.

/// \param length Number of 32-bit numbers to generate.

extern void ulp_rand(UINT32* buffer, UINT32 length);

UINT32 rand_num;

ulp_rand(&rand_num, 1);

Unfortunately, this is not available with SDK 1.1.0.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Thanks for answer.

I use SDK 1.1.0.

For get a random number don`t use SDK ,do you have any good Suggestions?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

I just did a search on Google and there are a number of SW methods of generating a pseudo-random number that you can implement in the app. If you need a seed for your random number generator, you may use the Bluetooth clock as the first seed value:

/// This function returns the current native Bluetooth clock; this

/// counter is 28 bits, and ticks every 312.5 us and is adjusted for

/// drift through sleep, etc. To compute differences and times elapsed,

/// use bleapputils_diffNativeBtClks() or bleapputils_BtClksSince().

/// \return the counter value.

UINT32 bleapputils_currentNativeBtClk(void);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

My suggestion would be to find an implementation of the Mersenne Twister. It is widely available and implemented in a lot of languages (Mersenne twister - Wikipedia, the free encyclopedia). It is known to have an very long period.