This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface Queue : NSObject { | |
NSMutableArray *queue; | |
int maxSize; | |
} | |
- (id)initWithSize:(int)maxSize; | |
- (id)dequeue; | |
- (void)enqueue:(id)anObject ; | |
- (int)count; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Queue初期化 | |
Queue *queue = [[Queue alloc] initWithSize:128]; | |
// NSDataをenqueue | |
NSData *indata = [[NSData alloc] init]; | |
... | |
[queue enqueue:indata]; | |
// すべてのNSDataをdequeue | |
while([queue count] > 0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 構造体の例 | |
typedef union _PacketT{ | |
uint8_t byte[10]; | |
struct { | |
uint8_t stx; | |
uint8_t id; | |
uint16_t address; | |
uint32_t data; | |
uint8_t checksum; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
// 背景をクリックしたら、キーボードを隠す | |
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(closeKeyboard)]; | |
gestureRecognizer.cancelsTouchesInView = NO; | |
[self.view addGestureRecognizer:gestureRecognizer]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void ble_stack_init(void) | |
{ | |
// Initialize SoftDevice. | |
SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, false); | |
// Subscribe for BLE events. | |
uint32_t err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch); | |
APP_ERROR_CHECK(err_code); | |
// Register with the SoftDevice handler module for BLE events. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Persistent storage system event handler | |
void pstorage_sys_event_handler (uint32_t p_evt); | |
/**@brief Function for dispatching a system event to interested modules. | |
* | |
* @details This function is called from the System event interrupt handler after a system | |
* event has been received. | |
* | |
* @param[in] sys_evt System stack event. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "app_scheduler.h" | |
... | |
// YOUR_JOB: Modify these according to requirements (e.g. if other event types are to pass through | |
// the scheduler). | |
#define SCHED_MAX_EVENT_DATA_SIZE sizeof(app_timer_event_t) /**< Maximum size of scheduler events. Note that scheduler BLE stack events do not contain any data, as the events are being pulled from the stack in the event handler. */ | |
#define SCHED_QUEUE_SIZE 10 /**< Maximum number of events in the scheduler queue. */ | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static uint8_t pstorage_wait_flag = 0; | |
static pstorage_block_t pstorage_wait_handle = 0; | |
static void flash_cb_handler(pstorage_handle_t *handle, | |
uint8_t op_code, | |
uint32_t result, | |
uint8_t *p_data, | |
uint32_t data_len) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void pstorage_test_store_and_load(void) | |
{ | |
pstorage_handle_t handle; | |
pstorage_handle_t block_handle; | |
pstorage_module_param_t param; | |
uint8_t source_data[16] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F}; | |
uint8_t source_data_2[16] = {0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0}; | |
uint8_t dest_data[16] = {0}; | |
uint32_t err_code; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(void) | |
{ | |
// Initialize | |
leds_init(); | |
timers_init(); | |
buttons_init(); | |
APP_GPIOTE_INIT(1); | |
uart_init(); | |
ble_stack_init(); | |
scheduler_init(); |
OlderNewer