示例#1
0
void button_scan(void * args)
{
  if(gpio_read(BUTTON))
  {
    button_state2 = 1;
  }
  else
  {
    button_state2 = 0;
  }
   
  if((button_state1 == 1) && (button_state2 == 0))
  {//fall
    if(button_count == 0)
    {
      button_count ++;
      run_after_delay(button_event_one_two, NULL, 500);
    }
    else 
    {
      button_count ++;
    }
  }

  button_state1 = button_state2; 
  run_after_delay(button_scan, NULL, 50);
}
示例#2
0
/* Device on connect */
void ble_device_on_connect(void)
{
    running = 1;

    run_after_delay(led_off, NULL, 150);
    run_after_delay(read_acc, NULL, UPDATE_INTERVAL);
}
示例#3
0
void on_ready()
{
  ble_device_set_name("JUMA_ADC_DEMO");
  gpio_setup(LED_1, GPIO_OUTPUT);

  run_after_delay(led_on_task, NULL, 100);
  
  run_after_delay(adc_task, NULL, 100);

  ble_device_set_advertising_interval(200);
  ble_device_start_advertising();
}
示例#4
0
void led_on_task(void* args)
{
  // Pull Up
  gpio_write(LED_1, 1);

  run_after_delay(led_off_task, NULL, 250);
}
示例#5
0
void breathing_led_run()
{
	LED_luminance+=10;
	if(LED_luminance>=1000)LED_luminance=-1000;
	TIM_PWM_Duty(&TimHandleT2,TIM_CHANNEL_2,abs(LED_luminance));
	run_after_delay(breathing_led_run, NULL, 10);
}
示例#6
0
void led_off_task(void* args)
{
  // Pull Down
  gpio_write(LED_1, 0);

  run_after_delay(led_on_task, NULL, 750);
}
示例#7
0
static void led_off(void* arg)
{
    if (!running) return;

    BSP_LED_Off(LED0);

    run_after_delay(led_on, NULL, 150);
}
示例#8
0
void on_ready()
{
  gpio_setup(LED_1, GPIO_OUTPUT);

  run_after_delay(led_on_task, NULL, 100);

  ble_device_set_name("JUMA_ECHO_DEMO");
  ble_device_start_advertising();
}
static void imu_sensor_magneto_data_handle(void* data)
{
    /*mag data*/
    if(LSM303AGR_MAG_Get_Magnetic(sensor_data.mag) != imu_status_ok)
    {
        printf("read sensor error\n");
        return ;
    }
    run_after_delay(imu_sensor_read_data_from_fifo, NULL,1);
}
示例#10
0
void button_init()
{
  button_state1 = 1;
  button_state2 = 1;
  
  button_count = 0;
  button_off_count = 0;

  gpio_setup(BUTTON, GPIO_INPUT_PULLUP);  
  run_after_delay(button_scan, NULL, 2000);
}
示例#11
0
void ble_host_on_device_info(void* data)
{
    uint8_t* temp_buf = data;
#ifdef CLIENT_ROLE
    scan_device_found_info* device_info = data;

#endif
#if CLIENT_SERVER_ROLE
    if(temp_buf[10] == AD_TYPE_MANUFACTURER_SPECIFIC_DATA) {
        temp_buf = temp_buf+9;
        run_after_delay(mesh_rx_scan_data, temp_buf,2);
    }
#endif
}
示例#12
0
static void read_acc(void* arg)
// sensor read accelerometer
{
    JSensor_AXIS_Typedef tdef;
    int8_t ACC[6], GRO[6];

    if (!running) return;

    tdef.ACC = ACC;
    tdef.GRO = GRO;

    if (JSENSOR_OK == jsensor_app_read_sensor(JSENSOR_TYPE_MOTION_6AXIS, (void *)&tdef)) {
        ble_device_send(0x04, 6, (uint8_t*)ACC);
    }

    run_after_delay(read_acc, NULL, UPDATE_INTERVAL);
}
示例#13
0
文件: app.c 项目: gilbertjuly/cannon
/*Accept humidity,tempreture data*/
void read_temp_hum(void* arg)
{
    uint8_t temp[2] = {0};
    uint16_t temp_1 = 0;
//	/*humity*/
    BSP_HUM_TEMP_GetHumidity(&humidity);
    temp_1 = (uint16_t)(humidity*100);
    temp[0] = temp_1 >> 8;
    temp[1] = temp_1 & 0xFF;
    ble_device_send(0x01, 2, temp);
    /*Temperature*/
    BSP_HUM_TEMP_GetTemperature(&temperature);
    temp_1 = (uint16_t)(temperature*100);
    temp[0] = temp_1 >> 8;
    temp[1] = temp_1 & 0xFF;
    ble_device_send(0x00, 2, temp);

    run_after_delay(read_temp_hum, NULL, 2000);
}
示例#14
0
void button_event_one_two(void * args)
{
  if(button_count >= 2)
  {//two click
    button_two_click();
    button_count = 0;
  }
  else 
  {
    if(gpio_read(BUTTON))
    {//one click
      
      button_one_click();
      button_count = 0;
    }
    else 
    {
      run_after_delay(button_is_long_push, NULL, 2000);
    }
  }
}
示例#15
0
/**
 * @brief  Callback processing the ACI events.
 * @note   Inside this function each event must be identified and correctly
 *         parsed.
 * @param  void* Pointer to the ACI packet
 * @retval None
 */
void HCI_Event_CB(void *pckt)
{
    hci_uart_pckt *hci_pckt = pckt;
    /* obtain event packet */
    hci_event_pckt *event_pckt = (hci_event_pckt*)hci_pckt->data;
    if(hci_pckt->type != HCI_EVENT_PKT)
        return;

    switch(event_pckt->evt) {

    case EVT_DISCONN_COMPLETE:
    {
     disconn_event_pckt *evt = (void *)event_pckt->data;
     printf("conn handle: %x\n", evt->conn_handle);
#if defined (CLIENT_ROLE) || defined (CLIENT_SERVER_ROLE)
        host_notification_enabled = 0;
#endif
        /*Host*/
       GAP_DisconnectionComplete_CB();
       /*device*/
       notification_enabled = 0;
       ble_device_on_disconnect(evt->disconn_reason);
     
    }
    break;
    
    case EVT_LE_META_EVENT:
    {
        evt_le_meta_event *evt = (void *)event_pckt->data;
        switch(evt->subevent) {
        case EVT_LE_CONN_COMPLETE:
        {
            evt_le_connection_complete *cc = (void *)evt->data;
            if(cc->role == SLAVE_ROLE){
                /*device*/
                ble_device_on_connect();
                connection_information(cc->handle);
            }
            if(cc->role == MASTER_ROLE){
                /*host*/
                GAP_ConnectionComplete_CB(cc->peer_bdaddr, cc->handle);
            }
        }
        break;
        case EVT_LE_ADVERTISING_REPORT:
        {
#if defined (CLIENT_ROLE) || defined (CLIENT_SERVER_ROLE)
            le_advertising_info* adv_data = (void *)((event_pckt->data)+2);
            run_after_delay(ble_host_device_found, adv_data, 2);
#endif
        }
        break;
        }
    }
    break;

    case EVT_VENDOR:
    {
        evt_blue_aci *blue_evt = (void*)event_pckt->data;
        switch(blue_evt->ecode) {
        case EVT_BLUE_GATT_ATTRIBUTE_MODIFIED:
        {
            /* this callback is invoked when a GATT attribute is modified
            extract callback data and pass to suitable handler function */
            evt_gatt_attr_modified *evt = (evt_gatt_attr_modified*)blue_evt->data;
            ///on message
            if(evt->att_data[1] > 0) {
                ble_device_on_message(evt->att_data[0], evt->att_data[1], (evt->att_data)+2);
            } else if(evt->att_data[0] == 1) {
                notification_enabled = 1;
#if defined (CLIENT_ROLE) || defined (CLIENT_SERVER_ROLE)
                host_notification_enabled = 1;
#endif
            }
        }
        break;
        case EVT_BLUE_GATT_NOTIFICATION:
        {
            evt_gatt_attr_notification *evt = (evt_gatt_attr_notification*)blue_evt->data;
            GATT_Notification_CB(evt->attr_handle, evt->event_data_length - 2, evt->attr_value);
        }
        break;
        case EVT_BLUE_GATT_READ_PERMIT_REQ:
        {
            evt_gatt_read_permit_req *pr = (void*)blue_evt->data;
            Read_Request_CB(pr->attr_handle);
        }
        break;
        case EVT_BLUE_GAP_DEVICE_FOUND:
        {
            printf("scanned one device\n\r");
        }
        break;
        case EVT_BLUE_GAP_PROCEDURE_COMPLETE:
        {
#ifdef CLIENT_SERVER_ROLE
            run_after_delay(ble_host_start_scan, NULL, 10);
            printf("EVT_BLUE_GAP_PROCEDURE_COMPLETE \n\r");
#endif
        }
        break;
        case EVT_BLUE_GATT_DISC_READ_CHAR_BY_UUID_RESP:
#if defined (CLIENT_ROLE) || defined (CLIENT_SERVER_ROLE)
            if(BLE_Role & CLIENT) {
                printf("EVT_BLUE_GATT_DISC_READ_CHAR_BY_UUID_RESP\n");

                evt_gatt_disc_read_char_by_uuid_resp *resp = (void*)blue_evt->data;

                if (start_read_write_char_handle && !end_read_write_char_handle)
                {
                    write_handle = resp->attr_handle;
                    printf("write_handle  %04X\n", write_handle);
                }
                else if (start_read_notify_read_char_handle && !end_read_notify_read_char_handle)
                {
                    notify_read_handle = resp->attr_handle;
                    printf("notify_read_handle  %04X\n", notify_read_handle);
                }
                else if (start_read_write_without_rsp_char_handle && !end_read_write_without_rsp_char_handle)
                {
                    write_without_rsp_handle = resp->attr_handle;
                    printf("write_without_rsp_handle  %04X\n", write_without_rsp_handle);
                }
                else if (start_read_notify_char_handle && !end_read_notify_char_handle)
                {
                    notify_handle = resp->attr_handle;
                    printf("notify_handle %04X\n", notify_handle);
                }
            }
#endif
            break;

        case EVT_BLUE_GATT_PROCEDURE_COMPLETE:
#if defined (CLIENT_ROLE) || defined (CLIENT_SERVER_ROLE)
            if(BLE_Role & CLIENT) {
                /* Wait for gatt procedure complete event trigger related to Discovery Charac by UUID */
                //evt_gatt_procedure_complete *pr = (void*)blue_evt->data;

                if (start_read_write_char_handle && !end_read_write_char_handle)
                {
                    end_read_write_char_handle = TRUE;
                    run_when_idle(ble_host_discover_char, NULL);

                }
                else if (start_read_notify_read_char_handle && !end_read_notify_read_char_handle)
                {
                    end_read_notify_read_char_handle = TRUE;
                    run_when_idle(ble_host_discover_char, NULL);
                }
                else if (start_read_write_without_rsp_char_handle && !end_read_write_without_rsp_char_handle)
                {
                    end_read_write_without_rsp_char_handle = TRUE;
                    run_when_idle(ble_host_discover_char, NULL);
                }
                else if (start_read_notify_char_handle && !end_read_notify_char_handle)
                {
                    end_read_notify_char_handle = TRUE;
                    run_when_idle(ble_host_discover_char, NULL);
                }
            }
#endif
            break;
        }
    }
    break;
    }
}
示例#16
0
void ble_device_on_disconnect(uint8_t reason)
{
    printf("device disconnected\n");
    run_after_delay(mesh_disconnect_handle, NULL, 100);
}
示例#17
0
static void led_on(void* arg)
{
    BSP_LED_On(LED0);

    run_after_delay(led_off, NULL, 100);
}
示例#18
0
void adc_task(void* args)
{
  adc_measure(ADC_PIN, 10, on_adc_complete);
  
  run_after_delay(adc_task, NULL, 500);
}
示例#19
0
文件: app.c 项目: joyxuyichao/JUMP
void on_ready()
{
  sys_driver_init();
 
  run_after_delay(system_start, NULL, 20);
}