Debug if I can write data to NVRAM

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello Community

I try to send digital value to iphone with Bluetooth when pio 0 input value change.

And I try to store data to NVRAM when transmission fail, and the stored all data will be sent when transmission success again.

I can send digital data to iphone, but I have no idea about NVRAM programming.

I use BCM20737 and debug with Light Blue app.

I would like to ask 3 questions.

1, When I check if data successfully can be written, I plug off Vcc jumper wire and plug again for power cycling. After power cycling I can't start the service. It doesn't appear on a list like figure 1. Please let me know how to check if  data can be written and keep it in NVRAM after power cycling. I should use another app or ?

2, I can change characteristic's data on iphone screen when pio 0's value change with following code which is refer to hello _sensor. When I watch value of writeNVRAM in bellow code with teraterm, it doesn't change and it's always 1. Please let me know to write value of sum in bellow code into NVRAM. sum's value is count up every change of pio 0's value.

3, I try to store data when transmission fail. There is any command to get callback when transmission fail?

I will really appreciate your help .

Thank you.

ka mi

-------------------------

void hello_sensor_send_message(void)

{

    BLEPROFILE_DB_PDU db_pdu;

    //UINT8 res = gpio_getPinInput(0,0);

    UINT8 res[100];

    UINT8 data = 0;

    UINT8 i;

    count++;

    res[count] = gpio_getPinInput(0,0);

    ble_trace1("count = %d\n",count);

    ble_trace2("res[%d] = %d\n", count, res[count]);

    sum = sum+res[count];

    ble_trace1("sum = %d\n", sum);

    // If client has not registered for indication or notification, do not need to do anything

    if (hello_sensor_hostinfo.characteristic_client_configuration == 0)

        return;

    // Read value of the characteristic to send from the GATT DB.

    bleprofile_ReadHandle(HANDLE_HELLO_SENSOR_VALUE_NOTIFY, &db_pdu);

    db_pdu.pdu[0x00] = (UINT8)sum;

    bleprofile_WriteHandle(HANDLE_HELLO_SENSOR_VALUE_NOTIFY, &db_pdu);

    ble_tracen((char *)db_pdu.pdu, db_pdu.len);

  writeNVRAM = bleprofile_WriteNVRAM(VS_BLE_HOST_LIST-10, sizeof(sum), (UINT8 *)&sum);

  writeNVRAM = bleprofile_ReadNVRAM(VS_BLE_HOST_LIST-10, sizeof(sum), (UINT8 *)&sum);

    ble_trace1("second NVRAM read:%04d\n", writeNVRAM);

-------------------------

0 Likes
1 Solution
Anonymous
Not applicable

1) Let me know what board you use.

You said you're using BCM20737. Do you mean BCM920737TAG board?

If yes, do you switch #2 of SW4 off after programming by IDE?

Please check WICED Smart Quick Start Guide (SDK 2.1 and TAG3 Board).

2) bleprofile_ReadNVRAM returns number of data read from NVRAM.

You specify "sizeof(sum)" as the length.

So it always returns 1 when sum is UINT8.

Please read the header file carefully.

3) There is no way to get whether NOTIFICATION is successfully.

You should use INDICATION if you want to know it.

Please get and read Bluetooth specification.

View solution in original post

0 Likes
5 Replies
Anonymous
Not applicable

1) Let me know what board you use.

You said you're using BCM20737. Do you mean BCM920737TAG board?

If yes, do you switch #2 of SW4 off after programming by IDE?

Please check WICED Smart Quick Start Guide (SDK 2.1 and TAG3 Board).

2) bleprofile_ReadNVRAM returns number of data read from NVRAM.

You specify "sizeof(sum)" as the length.

So it always returns 1 when sum is UINT8.

Please read the header file carefully.

3) There is no way to get whether NOTIFICATION is successfully.

You should use INDICATION if you want to know it.

Please get and read Bluetooth specification.

0 Likes
Anonymous
Not applicable

dmiya, thank you for replying.

>> Let me know what board you use.

I'm using Koshian board equipped with BCM20737S(Koshian - Mpression), and I used USB serial connectorhttps://www.sparkfun.com/products/retired/8772

to connect koshian and PC. When I pull off and on the Vcc jumper wire connected to the USB serial connector for check writing to NVRAM, I can't start Hello sensor service as figure 1 which I sent. There is not NVRAM in the BMC20737S ? should I connect NVRAM externally throgh I2c? Please let me know how to check if it successfully have done a writing to NVRAM with Light Blue app or other necessary iphone app.

Thank you

0 Likes
Anonymous
Not applicable

Hello dmiya

Thank you for your replying, I have still have some questions.

1) Actually I didn't use BCM920737TAG board.

Should I use this board to write or read data in NVRAM? I still use koshian which is BCM20737 module.

If I  develop a process of writing and reading in NVRAM with this board, BCM20737 work without this board when I deploy BCM20737 on a circuit ?

2)when I define sum UINT16, data output 2, but after it change 2, it has never change.

I would like this number to count up when input pin is high.

here are my code

-------------------------

UINT8 count;

UINT16 sum;

int  writeNVRAM;

UINT8 res[100];

void hello_sensor_send_message(void)

{

    BLEPROFILE_DB_PDU db_pdu;

    UINT8 val = gpio_getPinInput(0,0);

    UINT8 data = 0;

    UINT8 i;

    count++;

    res[count] = gpio_getPinInput(0,0);

    ble_trace1("count = %d\n",count);

    ble_trace2("res[%d] = %d\n", count, res[count]);

    sum = sum+res[count];

    //ble_trace1("sum = %d\n", sum);

    // If client has not registered for indication or notification, do not need to do anything

    if (hello_sensor_hostinfo.characteristic_client_configuration == 0)

        return;

    // Read value of the characteristic to send from the GATT DB.

    bleprofile_ReadHandle(HANDLE_HELLO_SENSOR_VALUE_NOTIFY, &db_pdu);

    db_pdu.pdu[0x00] = (UINT8)sum;

    bleprofile_WriteHandle(HANDLE_HELLO_SENSOR_VALUE_NOTIFY, &db_pdu);

    ble_tracen((char *)db_pdu.pdu, db_pdu.len);

    //sum =0x01;

  writeNVRAM = bleprofile_ReadNVRAM(0x10, sizeof(sum), (UINT8 *)&sum);

    ble_trace1("BEFORE NVRAM read:%04d\n", writeNVRAM);

    //sum = 0x03;

  writeNVRAM = bleprofile_WriteNVRAM(0x10, sizeof(sum), (UINT8 *)&sum);

    ble_trace1("Write value:%04d\n", writeNVRAM);

  writeNVRAM = bleprofile_ReadNVRAM(0x10, sizeof(sum), (UINT8 *)&sum);

    ble_trace1("AFTER NVRAM read:%04d\n", writeNVRAM);

-------------------------

3) I will search INDICATION! Thank you.

I am a beginner of this programming.

I will really appreciate your kind support.

Thank you

ka mi

0 Likes
Anonymous
Not applicable

Hi,

About 1), I think it's not related with NVRAM.

After programming your application to BCM20737S, it will automatically run.

UART RX is still connected (pulled-up). Then it won't run after power cyble.

Please see section3 of Quick Start Guide.

2) bleprofile_WriteNVRAM() returns length successfully written.

So when you specify sizeof(sum) as second parameter, it always return 2.

If you want to overwrite sum to NVRAM, please refer below code (not tested).

-----

...

UINT8 temp = 0x00;

if (sizeof(temp) != bleprofile_ReadNVRAM(0x10, sizeof(temp), (UINT8 *)&temp)) {

    return;

}

ble_trace1("BEFORE NVRAM read:%04d\n", temp);

temp += res[count];

if (sizeof(temp) != bleprofile_WriteNVRAM(0x10, sizeof(temp), (UINT8 *)&temp)) {

    return;

}

if (sizeof(temp) != bleprofile_ReadNVRAM(0x10, sizeof(temp), (UINT8 *)&temp)) {

    return;

}

ble_trace1("AFTER NVRAM read:%04d\n", temp);

-----

Anonymous
Not applicable

I am sorry for replying late.

your advise is really helpful.

I will learn more using your advise.

Thank you

0 Likes