This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

netapp_dhcp error

I lost 2 days figuring this out. The definition of  function is

INT32 netapp_dhcp(UINT32 *aucIP, UINT32 *aucSubnetMask,UINT32 *aucDefaultGateway, UINT32 *aucDNSServer)

so naturaly you put array of UINT32 values e.g.

UINT32 Static_IP[4];

In the netapp_dhcp() function it is used macro

#define ARRAY_TO_STREAM(p, a, l) {register INT16 _i; for (_i = 0; _i < l; _i++) *(p)++ = ((UINT8 *) a)[_i];}

and this mean it takes byte by byte from UINT32 array. UINT32 array have 4 bytes for one value so 192 is written as 192, 0, 0, 0. So the wrong values are saved to CC3000 EEPROM.

I am using LPC18xx and host driver v1.14.

And another thing. In head comment of this function are wrong instructions:

//!  @param  aucIP               device mac address, 6 bytes. Saved: yes 
//!  @param  aucSubnetMask       device mac address, 6 bytes. Saved: yes 
//!  @param  aucDefaultGateway   device mac address, 6 bytes. Saved: yes 
//!  @param  aucDNSServer        device mac address, 6 bytes. Saved: yes 

  • Hi,

    Thanks for pointing out on the API documentation. We will take a look at it.

    Regarding the parameters being UINT32, the netapp_dhcp actually accepts address of a UINT32 variable. The point that you have mentioned is valid. But passing the address of a UINT32 variable is the right way call the API.

    For example, if you want to set the static IP as 192.168.1.9, then set the variable Static_IP as follows:
    UINT32 Static_IP = 0x0901A8C0;

    And pass the address of Static_IP to the netapp_dhcp API.

    Regards,
    Raghavendra
  • Raghavendra Shenoy said:
    Hi,
    For example, if you want to set the static IP as 192.168.1.9, then set the variable Static_IP as follows:
    UINT32 Static_IP = 0x0901A8C0;

    I understand this now but it is not intuitive way to do something like this. So if you want to change IP, you have to calculate HEX and watch out for endianness. Besides, it would be very helpful if you put above instruction into the API documentation .But I solved the problem like this:

    UINT8 Static_IP[]={192,168,123,186};
    netapp_dhcp((UINT32 *)Static_IP,...

  • Hi,

    Sure. We will take a look at the API documentation. Thanks for the feedback.

    Regards,
    Raghavendra