Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //my structure
- typedef struct MyData_s
- {
- uint8_t SPP_buffer[BUF_SIZE];
- uint8_t UART_buffer[BUF_SIZE];
- uint32_t SPP_len;
- uint32_t UART_len;
- uint8_t SPP_got_packet;
- uint8_t UART_got_packet;
- bool SPP_conn; // TRUE: spp connected
- }MyData_t;
- MyData_t MyData;
- // SPP callback
- static void esp_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
- {
- ...
- case ESP_SPP_CLOSE_EVT:
- ESP_LOGI(SPP_TAG, "ESP_SPP_CLOSE_EVT"); // when client disconnects
- MyData.SPP_conn = false;
- break;
- case ESP_SPP_SRV_OPEN_EVT:
- ESP_LOGI(SPP_TAG, "ESP_SPP_SRV_OPEN_EVT"); // client connected
- FlowMeterData.SPP_conn = true;
- break;
- case ESP_SPP_DATA_IND_EVT:
- ESP_LOGI(SPP_TAG, "ESP_SPP_DATA_IND_EVT len=%d handle=%d", param->data_ind.len, param->data_ind.handle);
- if (param->data_ind.len < 1023)
- {
- // this part tranferring data fom SPP to UART (at this stage only fills the proper buffer, later it will be handled)
- memcpy(MyData.SPP_Buf,param->data_ind.data, (size_t)param->data_ind.len);
- MyData.SPP_len = param->data_ind.len;
- MyData.SPP_got_packet = true;
- // And this part works ONLY if I send something via SPP (I need independence sending)
- if(MyData.UART_got_packet == true)
- {
- esp_spp_write(param->write.handle, MyData.UART_len, MyData.UART_buffer);
- MyData.UART_got_packet = false;
- }
- }
- ...
- }
- // My function that should write data from UART to SPP outside spp callbacks
- void SPP_to_UART_write(esp_spp_cb_param_t param)
- {
- esp_spp_write(param.write.handle, MyData.UART_len, MyData.UART_buffer);
- }
- //Main
- void app_main()
- {
- ...
- // maybe like this?
- esp_spp_cb_param_t my_param;
- my_param.write.handle = ???; // 129 ?
- SPP_to_UART_write(my_param)
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement