kopia lustrzana https://github.com/SP8EBC/ParaTNC
bugfix in serial port driver and sim800 engineering
rodzic
ed076e7cba
commit
7facd24b9d
|
@ -995,7 +995,7 @@ int main(int argc, char* argv[]){
|
|||
|
||||
// gsm_sim800_engineering_enable(main_gsm_srl_ctx_ptr, &main_gsm_state);
|
||||
// gsm_sim800_engineering_request_data(main_gsm_srl_ctx_ptr, &main_gsm_state);
|
||||
// gsm_sim800_engineering_disable(main_gsm_srl_ctx_ptr, &main_gsm_state);
|
||||
//gsm_sim800_engineering_disable(main_gsm_srl_ctx_ptr, &main_gsm_state);
|
||||
}
|
||||
|
||||
// if Victron VE.direct client is enabled
|
||||
|
|
|
@ -552,7 +552,7 @@ void srl_irq_handler(srl_context_t *ctx) {
|
|||
|
||||
// checking if this byte in stream holds the protocol information about
|
||||
// how many bytes needs to be received.
|
||||
if (ctx->srl_rx_lenght_param_addres == ctx->srl_rx_bytes_counter) {
|
||||
if (ctx->srl_rx_lenght_param_addres == ctx->srl_rx_bytes_counter && ctx->srl_rx_lenght_param_addres != 0xFF) {
|
||||
len_temp = ctx->srl_rx_buf_pointer[ctx->srl_rx_bytes_counter];
|
||||
|
||||
// adding (or substracting) a length modifier
|
||||
|
|
|
@ -104,18 +104,36 @@ void gsm_sim800_check_for_async_messages(uint8_t * ptr, uint16_t size, uint16_t
|
|||
|
||||
int comparision_result = 123;
|
||||
|
||||
int start_i = 0;
|
||||
|
||||
// simplified check, not to waste time for full strncmp
|
||||
if (*ptr == 'R') {
|
||||
comparision_result = strncmp(INCOMING_CALL, (const char *)ptr, (size_t)INCOMING_CALL_LN);
|
||||
|
||||
if (comparision_result == 0) {
|
||||
start_i = INCOMING_CALL_LN;
|
||||
}
|
||||
}
|
||||
else if (*ptr == 'N') {
|
||||
comparision_result = strncmp(NOCARRIER, (const char *)ptr, (size_t)NOCARRIER_LN);
|
||||
|
||||
if (comparision_result == 0) {
|
||||
start_i = NOCARRIER_LN;
|
||||
}
|
||||
}
|
||||
else if (*ptr == 'S') {
|
||||
comparision_result = strncmp(SMS_RDY, (const char *)ptr, (size_t)SMS_RDY_LN);
|
||||
|
||||
if (comparision_result == 0) {
|
||||
start_i = SMS_RDY_LN;
|
||||
}
|
||||
}
|
||||
else if (*ptr == 'C') {
|
||||
comparision_result = strncmp(CALL_RDY, (const char *)ptr, (size_t)CALL_RDY_LN);
|
||||
|
||||
if (comparision_result == 0) {
|
||||
start_i = CALL_RDY_LN;
|
||||
}
|
||||
}
|
||||
else if (*ptr == 'O') {
|
||||
comparision_result = strncmp(OVP_WARNING, (const char *)ptr, (size_t)OVP_WARNING_LN);
|
||||
|
@ -123,6 +141,9 @@ void gsm_sim800_check_for_async_messages(uint8_t * ptr, uint16_t size, uint16_t
|
|||
if (comparision_result != 0) {
|
||||
comparision_result = strncmp(OVP_PDWON, (const char *)ptr, (size_t)IVP_PDWON_LN);
|
||||
}
|
||||
else {
|
||||
start_i = OVP_WARNING_LN;
|
||||
}
|
||||
}
|
||||
else if (*ptr == 'U') {
|
||||
comparision_result = strncmp(UVP_WARNING, (const char *)ptr, (size_t)UVP_WARNING_LN);
|
||||
|
@ -130,12 +151,15 @@ void gsm_sim800_check_for_async_messages(uint8_t * ptr, uint16_t size, uint16_t
|
|||
if (comparision_result != 0) {
|
||||
comparision_result = strncmp(UVP_PDOWN, (const char *)ptr, (size_t)UVP_PDOWN_LN);
|
||||
}
|
||||
else {
|
||||
start_i = UVP_WARNING_LN;
|
||||
}
|
||||
}
|
||||
|
||||
// check if this has been found
|
||||
if (comparision_result == 0) {
|
||||
// if yes rewind to the start of response
|
||||
for (int i = INCOMING_CALL_LN; i < size && *(ptr + i) != 0; i++) {
|
||||
for (int i = start_i; i < size && *(ptr + i) != 0; i++) {
|
||||
if (*(ptr + i) > 0x2A && *(ptr + i) < 0x5B) {
|
||||
// start the check from '+' and end on 'Z'
|
||||
*offset = (uint16_t)i;
|
||||
|
@ -468,7 +492,7 @@ uint8_t gsm_sim800_rx_terminating_callback(uint8_t current_data, const uint8_t *
|
|||
|
||||
// special case for CENG request
|
||||
if (gsm_at_command_sent_last == ENGINEERING_GET) {
|
||||
gsm_terminating_newline_counter = 4;
|
||||
gsm_terminating_newline_counter = 10;
|
||||
}
|
||||
else if (gsm_at_command_sent_last == GET_CONNECTION_STATUS) {
|
||||
gsm_terminating_newline_counter = 4;
|
||||
|
@ -514,6 +538,8 @@ void gsm_sim800_rx_done_event_handler(srl_context_t * srl_context, gsm_sim800_st
|
|||
|
||||
uint32_t newlines = 0;
|
||||
|
||||
uint16_t new_start_idx = 0;
|
||||
|
||||
gsm_waiting_for_command_response = 0;
|
||||
|
||||
if (srl_context->srl_rx_state == SRL_RX_ERROR) {
|
||||
|
@ -523,16 +549,28 @@ void gsm_sim800_rx_done_event_handler(srl_context_t * srl_context, gsm_sim800_st
|
|||
// check how many lines of text
|
||||
newlines = gsm_sim800_check_for_extra_newlines(srl_context->srl_rx_buf_pointer + gsm_response_start_idx, srl_context->srl_rx_buf_ln);
|
||||
|
||||
// if a library expects only single line of response
|
||||
if (gsm_terminating_newline_counter == 1) {
|
||||
// if more than single line of response has been received
|
||||
if ((newlines & 0xFFFFFF00) != 0) {
|
||||
// if more than one line of response has been received
|
||||
second_line = (newlines & 0x0000FF00) >> 8;
|
||||
third_line = (newlines & 0x00FF0000) >> 16;
|
||||
fourth_line = (newlines & 0xFF000000) >> 24;
|
||||
|
||||
if (second_line != 0) {
|
||||
gsm_sim800_check_for_async_messages(srl_context->srl_rx_buf_pointer + gsm_response_start_idx + second_line, srl_context->srl_rx_buf_ln, & gsm_response_start_idx);
|
||||
gsm_sim800_check_for_async_messages(srl_context->srl_rx_buf_pointer + gsm_response_start_idx + second_line, srl_context->srl_rx_buf_ln, & new_start_idx);
|
||||
}
|
||||
|
||||
if (third_line != 0) {
|
||||
gsm_sim800_check_for_async_messages(srl_context->srl_rx_buf_pointer + gsm_response_start_idx + third_line, srl_context->srl_rx_buf_ln, & new_start_idx);
|
||||
}
|
||||
|
||||
if (fourth_line != 0) {
|
||||
gsm_sim800_check_for_async_messages(srl_context->srl_rx_buf_pointer + gsm_response_start_idx + fourth_line, srl_context->srl_rx_buf_ln, & new_start_idx);
|
||||
}
|
||||
}
|
||||
|
||||
if (new_start_idx != 0 && new_start_idx != gsm_response_start_idx) {
|
||||
|
||||
}
|
||||
|
||||
// if the library expects to receive a handshake from gsm module
|
||||
|
|
|
@ -134,7 +134,7 @@ void gsm_sim800_engineering_disable(srl_context_t * srl_context, gsm_sim800_stat
|
|||
|
||||
void gsm_sim800_engineering_request_data(srl_context_t * srl_context, gsm_sim800_state_t * state) {
|
||||
|
||||
if (*state == SIM800_ALIVE && gsm_sim800_engineering_is_enabled == 1) {
|
||||
if (*state == SIM800_ALIVE && gsm_sim800_engineering_is_enabled == 1 && gsm_sim800_engineering_successed == 0) {
|
||||
|
||||
// clear the flag
|
||||
gsm_sim800_engineering_successed = 0;
|
||||
|
@ -166,33 +166,25 @@ void gsm_sim800_engineering_response_callback(srl_context_t * srl_context, gsm_s
|
|||
}
|
||||
else if (gsm_at_command_sent_last == ENGINEERING_GET) {
|
||||
|
||||
// check if anything has been received
|
||||
if (srl_context->srl_rx_state == SRL_RX_ERROR) {
|
||||
|
||||
gsm_sim800_engineering_successed = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
else {
|
||||
gsm_sim800_engineering_successed = 1;
|
||||
}
|
||||
|
||||
// look for the start of '+CENG: 0,' record
|
||||
uint16_t ceng_start = gsm_sim800_rewind_to_ceng_0(srl_context->srl_rx_buf_pointer, srl_context->srl_rx_buf_ln, gsm_response_start_idx);
|
||||
|
||||
// if it has been found
|
||||
gsm_sim800_engineering_parse_ceng_0(srl_context->srl_rx_buf_pointer, ceng_start);
|
||||
}
|
||||
else if (gsm_at_command_sent_last == ENGINEERING_DISABLE) {
|
||||
int comparision_result = strcmp(OK, (const char *)(srl_context->srl_rx_buf_pointer + gsm_response_start_idx));
|
||||
if (ceng_start != 0xFFFF) {
|
||||
// if it has been found
|
||||
gsm_sim800_engineering_parse_ceng_0(srl_context->srl_rx_buf_pointer, ceng_start);
|
||||
|
||||
if (comparision_result == 0) {
|
||||
gsm_sim800_engineering_is_enabled = 0;
|
||||
gsm_sim800_engineering_successed = 1;
|
||||
|
||||
//gsm_sim800_engineering_disable(srl_context, state);
|
||||
}
|
||||
else {
|
||||
;
|
||||
gsm_sim800_engineering_successed = 0;
|
||||
}
|
||||
|
||||
}
|
||||
else if (gsm_at_command_sent_last == ENGINEERING_DISABLE) {
|
||||
gsm_sim800_engineering_is_enabled = 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -165,5 +165,9 @@ void sim800_gprs_response_callback(srl_context_t * srl_context, gsm_sim800_state
|
|||
if (comparision_result != 0) {
|
||||
*state = SIM800_NOT_YET_COMM;
|
||||
}
|
||||
|
||||
if (gsm_sim800_gprs_ready == 1) {
|
||||
*state = SIM800_ALIVE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include "gsm/sim800c_gprs.h"
|
||||
#include <stdint.h>
|
||||
|
||||
uint8_t sim800_poolers_five = 4;
|
||||
uint8_t sim800_poolers_five = 3;
|
||||
|
||||
void gsm_sim800_poolers_one_minute(srl_context_t * srl_context, gsm_sim800_state_t * state){
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue