LairdCP / BL652-Applications

Laird Connectivity BL652 smartBASIC applications
ISC License
22 stars 20 forks source link

BL652 with a MS5803 pressure sensor #4

Closed ibolution closed 6 years ago

ibolution commented 6 years ago

Hello everybody,

I try to do the following:

Four modules are to measure the pressure and the values should then be sent to a fifth module.

I try to write two codes. For the four modules I want to write a code as a client and for the one moduel the values receives a code as a server.

The code for the server is ready. Server and client connect but I can not get it that he receives the data. How can I do that the values arrive here?

The code for the clients is a bit harder. On the board is a MS5803 pressure sensor on it, which should measure pressure. I found an example code in the language C, which I am trying to rewrite in smartBASIC. The CRC check, but I can not continue because I am constantly displayed errors.

These two problems have, it would be great if someone could help me or give me tips

In this document is the sample code for the pressure sensor in c: MS5803.pdf

`//Client--CRC check

n_rem = 0x00 crc_read = sensorCoefficients[7] //save read CRC sensorCoefficients[7] = ( 0xFF00 & ( sensorCoefficients[7] ) ) //CRC byte is replaced by 0

for count=0 to 16 //operation is performed on bytes

if ( count%2 == 1 ) n_rem ^= ( ( sensorCoefficients[count>>1] ) & 0x00FF ) //choose LSB or MSB else n_rem ^= (sensorCoefficients[count>>1]>>8)

for (n_bit=8; n_bit>0; n_bit--)

    if (n_rem&(0x800))
        n_rem=(n_rem<<1) ^ 0x3000
    else n_rem = (n_rem<<1)

n_rem = (0x00F & (n_rem >> 12)) sensorCoefficients[7] = crc_read`

`//SERVER--- receive value

FUNCTION HandlerCharVal(BYVAL hChar_written AS INTEGER, BYVAL offset, BYVAL len) AS INTEGER

// Characteristic handle that was returned when the characteristic was registered using the function

BleCharCommit() PRINT "beispeiltext" // ----> error, is not displayed DIM attr$ IF hChar_written == hChar THEN rc = BleCharValueRead(hChar,attr$) //Read the value print "\n written to service: ";attr$ IF ms_buffer_pos>=MEASUREMENT_BUFFER_SIZE THEN
//If Buffer full, than stop. Otherwise save the pressure and who send it

PRINT "\n buffer full, can't accept more measurements" ELSE //ToDo: have to split up the message into id and value! ms_buffer_value[ms_buffer_pos]=STRVALDEC(attr$) //Save the pressure value ms_buffer_id[ms_buffer_pos]=STRVALDEC(attr$) //Save who sent it ms_buffer_pos=ms_buffer_pos+1

ENDIF ENDIF ENDFUNC 1`

thedjnK commented 6 years ago

This repository hosts sample BL652 applications, the issue reporting feature of this repository is only for reporting problems with sample applications which are hosted here. For assistance in developing an application can you please contact Laird EWS Support using this form: https://www.lairdtech.com/support/product-support/embedded-wireless/embedded-wireless-support-centre and they'll be able to help you.